JSPM

stratoxcontainer

1.0.0
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 1
    • Score
      100M100P100Q9293F
    • License Apache-2.0

    JavaScript container library designed for seamless communication between your libraries.

    Package Exports

      This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (stratoxcontainer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

      Readme

      StratoxContainer

      JavaScript container library designed for seamless communication between your libraries.

      Initialize

      import { StratoxContainer } from './node_modules/stratox/src/StratoxContainer.js';
      const container = new StratoxContainer();

      Examples

      // Example 1
      container.set("someObject", { test: "Container 1" });
      
      console.log(container.get("someObject").test);
      // Log response: Container 1
      
      // Example 2
      container.set("passingAFunction", function(arg1, arg2) {
          alert(arg1+" "+arg2);
      });
      
      container.get("passingAFunction", "Hello", "world!");
      // Alert response: Hello world!

      Method list

      Set a container or factory

      set(key, value, overwrite);
      • key: Unique container key/string identifier
      • value: Mixed value of whatever you want to share, e.g. String, number, object, function.
      • overwrite: Attempting to set a container multiple times will trigger a warning unless manual consent is provided by setting "overwrite" to true.

      Set factory only

      setFactory(key, value, overwrite);
      • key: Unique factory key/string identifier
      • value: callable
      • overwrite: Attempting to set a container multiple times will trigger a warning unless manual consent is provided by setting "overwrite" to true.

      Get a container or factory

      get(key, ...args);
      • key: Unique container key/string identifier
      • args: pass arguments to possible factory/function

      Check if container/factory exists

      has(key);
      • key: Unique container key/string identifier

      Check if is strict a "container".

      isContainer(key);
      • key: Unique container key/string identifier

      Check if is strict a "factory/function".

      isFactory(key);
      • key: Unique factory key/string identifier