Skip to content

Allow Literal Promises #21

Open
Open
@codechaotic

Description

@codechaotic

When a promise is registered as a literal the promise gets awaited before it is provided to another consumer. This should not be the case.

Example

// Contrived promise for a long waiting process. This may be a promise for an event used by other consumers such
as the process.exit signal or another system event.
const timeout = new Promise((resolve, reject) => {
  setTimeout(resolve, 10e3)
})

container.literal('timeout', timeout)

container.invoke(({ timeout }) => {
  // This is not executed until the timeout is reached since Diminish is interally waiting for the promise before
  // it will execute the invoked function.
  console.log(typeof timeout) // undefined
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions