Skip to content

Enable asynchronous Instantiation. #7

@h4cc

Description

@h4cc

Currently, Einigeln is fully synchronous. This could be changed with some additional API parameters.

Example:

di.set('foo', function(container, resolve) {
  // Not returning any value here, so Einigeln will assume resolve will be called when ready.
  setTimeout(function() {
    resolve(new Foo(container.get('bar')));
  }, 1000);
});

The additional API Call:

di.getAsync('foo').then(console.log);

For such a feature, get() needs to realize when a service used returnand when it using resolve.
So kind of a Map with a flag for each service if it is async needs to be added. Depending on that flag either get or getAsync will access each other on behalf.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions