Skip to content

Releases: molszanski/iti

0.7.0 - ESM / CJS

18 Nov 09:25
97bbc1e
Compare
Choose a tag to compare

What's Changed

0.5.0

08 Oct 01:08
Compare
Choose a tag to compare

What's Changed

Container Disposal

basic usage

import { createContainer } from "iti"

container = createContainer()
  .add({ a: () => "123" })
  .addDisposer({ a: () => {} })

container.get("a") === "123" // true
await container.disposeAll() // Promise<void>

async case

const container = createContainer()
  .add(() => ({
    dbConnection: async () => {
      /** connect to db and return an instance */
    },
  }))
  .addDisposer({
    //              ↓ `db` is a resolved value of a `dbConnection` token. Pretty handy
    dbConnection: (db) => db.close(),
  })

const db = await container.get("dbConnection")
await container.disposeAll()

Much Better Ts performance

Some huge projects consumed too much RAM and had some perf limits:
i18next/react-i18next#1417
TS2589: Type instantiation is excessively deep and possibly infinite
This was one of know issues:
https://itijs.org/docs/patterns-and-tips#known-issues

I believe that the issue is solved with this release

Full Changelog: 0.4.2...0.5.0

0.4.2

24 Jul 15:28
Compare
Choose a tag to compare

What's Changed

Full Changelog: 0.2.0...0.4.2

0.2.0

01 Feb 22:29
Compare
Choose a tag to compare

0.2.0 adds containerRequested, containerCreated and containerRemoved events

const kitchenApp = new RootContainer((ctx) => ({
  // you can use tokens (`oven`, `kitchen`) here and later on
  oven: async () => ovenContainer(),
  kitchen: async () => kitchenContainer(await ctx.oven()),
}))

kitchenApp.on("containerCreated", (event) => {
  console.log(`event: 'containerCreated' ~~> token: '${event.key}'`)
  // `event.container` is also avaliable here
})

kitchenApp.on("containerRequested", (event) => {
  console.log(`event: 'containerRequested' ~~> token: '${event.key}' `)
})

kitchenApp.on("containerRemoved", (event) => {
  console.log(`event: 'containerRemoved' ~~> token: '${event.key}' `)
})

await kitchenApp.containers.kitchen

// event: 'containerRequested' ~~> token: 'kitchen'
// event: 'containerRequested' ~~> token: 'oven'
// event: 'containerCreated'   ~~> token: 'oven'
// event: 'containerCreated'   ~~> token: 'kitchen'

// Notice how oven was created before kitchen.
// This is because kitcen depends on oven

What's Changed

Full Changelog: https://github.com/molszanski/snow-splash/commits/0.2.0