easilyBaffled / ioc-container

Created with StackBlitz ⚡️

Home Page:https://stackblitz.com/edit/vitest-dev-vitest-wbtgvr

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inversion of Control Container

This project represents an initial attempt at building an Inversion of Control Container. The majority of the code exists in src/ioc-container/container.ts I wrote a test suite to hold me to the mark as well as work as examples. You can see the tests in action by running npm run test:ui

Notes

TS

I chose to use Typescript for the project, though it does not always agree with what I am doing. I am using a Proxy to allow access to properties on an object that aren't actually there. As such it is hard to let TS know how to handle these things.

Edit on StackBlitz ⚡️

  • 🥦 setup project infrastructure

  • 🥦 create initial tests

  • 🥦 create roadmap

  • 🥦 create type def for container

  • 🥦 create initial container

    • 🥦 register Map
    • 🥦 initialized Map
    • 🥦 isRegistered, hasInstance for debugging
    • 🥦 register function
    • 🍰 unregister function
    • 🥦 get handling
    • 🥦 happy path tests passing
    • 🍰 error handling tests passing
    • 🥦 Inject
  • 🥦 revisit roadmap

  • 🥦 Clean UP

    • 🥦 Pull out types
    • 🍰 Fix type errors
    • [ x 🥦 Pull util functions
    • 🥦 Document functionality
    • 🥦 Document strange parts
    • 🥦 Update README
  • 🍰 example app using container

    • 🥦 register DB
    • 🥦 register Auth
    • 🥦 register User API
    • 🥦 Inject User API
  • 🍰 Add Lifecycle Handling for each service

    • 🥦 create tests for creation lifecycles
    • 🥦 beforeCreation
    • 🥦 afterCreate
    • 🍰 create tests for other lifecycles
    • 🍰 onGet
    • 🍰 beforeKill
    • 🍰 afterKill
  • 🍰 Other Service Options

    • 🍰 Singleton vs Transient
    • 🍰 Memoize
    • 🍰 Hidden
    • 🍰 beforeKill

About

Created with StackBlitz ⚡️

https://stackblitz.com/edit/vitest-dev-vitest-wbtgvr


Languages

Language:TypeScript 84.4%Language:JavaScript 15.6%