feat(RefSubject): get/unsafeGet(Exit) #47
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
RefSubject.get
RefSubject
,Computed
, andFiltered
, returning an Effect for their current values.RefSubject.unsafeGetExit
The
unsafeGet
method has been added to each interface forRefSubject
,Computed
, andFiltered
, and this function just defers to their implementations.It truly is UNSAFE, and WILL throw if a value has not been initialized. For
RefSubject
, onlyRefSubject.of(value)
, has a value directly after construction, all others will still require being initialized in an Effect runtime before being called, or else it will throw aCause.NoSuchElementException
. For more custom use cases,RefSubject.unsafeMake
accepts aninitialValue
option as well.There are
RefSubject.tagged
andRefSubject.fromTag
which will immediately throw with an error message that they do not supportunsafeGet
at all because they require the Effect context by definition. If this is necessary, useRefSubject.provide
to provide those services, and useEffect.runSync(RefSubject.get(ref))
For Computed and Filtered, because they both require Effectful computations, they always require an initialization before being able to sucessfully call
unsafeGetExit
RefSubject.unsafeGet
This is implemented as just
Effect.runSync(RefSubject.unsafeGetExit(ref))
, such that any Exit failures are thrown with their Causes in the same way that Effect would.Possibly closes #46