You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But what if we want to have some default behaviour or initial state for the service? We can't provide a default value for a token.
To get same result we can do it like so:
Hey @coolassassin, thanks for the proposal.
While I see some benefits here I also see that this would bloat the API: optionalToken('authToken')<string>('defaultToken') is essentially an alias to injectable('authToken', (): string => 'defaultToken').
Regarding inconsistency, I'm not sure I'm following since current implementation is consistent with the statement that a "token" is a dependency that the caller must provide when invoking the computation, and "injectable" is a computation itself with a default value which can be overridden.
The above means that if you want an optional dependency - you'd typically declare it as token('dependency')<string | undefined>(), but you'd have to explicitly provide the key - root({ dependency: undefined }).
I might be missing something here, but for now the current state of things seems consistent to me. Still, let's keep this open so that we could all think about this a bit more.
Hello!
If we imagine some kind of service which behaviour can be controlled outside (for example auth tokens), we would use tokens for that like so:
But what if we want to have some default behaviour or initial state for the service? We can't provide a default value for a token.
To get same result we can do it like so:
Which is ok and work, but it seems inconsistent to use different ways for close purposes.
So, I would like to offer to make an optional token like so:
The text was updated successfully, but these errors were encountered: