Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

snow-splash

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

snow-splash

> Tiny 1kB inversion of control container for Typescript/Javascrith with a focus on async flow

  • 0.1.5
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Snow Splash

Tiny 1kB inversion of control container for Typescript/Javascrith with a focus on async flow

  • fully async: merges async and constructor injection via an asynchronous Factory (async function)
  • pure: does not pollute business logic with decorators or magic properties
  • typesafe: works well with typescript
  • react: has useful react bindings
  • lightweight: doesn't rely on 'reflect-metadata' or decorators
  • tiny: ~1kB

About

snow-splash is a tyiny inversion of control (IoC) container for TypeScript and JavaScript apps. An IoC container provides a way to combine async flow and construction injection

Motivation

Inversion of Control (IoC) is a great way to decouple the application and the most popular pattern of IoC is dependency injection (DI) but it is not limited to one.

In JavaScript there is not way to create a dependency injection without polluting business logic with a specific IoC library code, or hacking a compiler.

snow-splash provides a pattern to use constructor injection that works in async JS world with all the flexibility you might need at the cost of manually defining providers (async functions) for your code

Usage

import mitt from "mitt";

const emitter = mitt();

// listen to an event
emitter.on("foo", (e) => console.log("foo", e));

// listen to all events
emitter.on("*", (type, e) => console.log(type, e));

// fire an event
emitter.emit("foo", { a: "b" });

// clearing all events
emitter.all.clear();

// working with handler references:
function onFoo() {}
emitter.on("foo", onFoo); // listen
emitter.off("foo", onFoo); // unlisten

old notes

Subjects:

  • event emitter: Rather domain scoped
  • hidden agenda / goal: share containeres and stores between projects

Containers:

  • what about instances shared between multiple containers? No!
  • Can we create "combined" contaners? Ok!

Notable inspirations:

Notes:

Sometimes we will need mobx transaction feature

FAQs

Package last updated on 27 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc