Skip to content

Conversation

@pikax
Copy link
Owner

@pikax pikax commented May 27, 2020

InjectFactory composable

Allows to inject to default to the factory result, instead of default value.

The factory will only be called when the value doesn't exist

Motivation

Sometimes building the defaultValue might be too costly to build every time we want to inject

// normal usage
injectFactory(myKey, ()=> { /* Heavy method */})

// promised based
await injectFactory(myKey, ()=> { /* Promised Heavy method */})

@pikax pikax added the composable New composable label May 27, 2020
@pikax pikax merged commit f571463 into master Jun 3, 2020
@pikax pikax deleted the feat/inject_factory branch June 3, 2020 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

composable New composable

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants