RxAccessStateUtils
Observable plumbing for access. The tri-state -- true | false | nil -- has to travel through
observables like any other value, and none of the obvious Rx operators carry nil:
Rx.startWith({nil})iterates its list, and a Lua list cannot hold nil, so it fires nothing.Rx.defaultsTo(nil)only fires on fail or complete, so a lookup still in flight emits nothing at all.Rx.of(nil)relies on varargs packing surviving a lone nil, and completes besides.
That matters because Rx.combineLatest waits for every source to emit once. A fact that stays silent until its lookup lands would keep the whole feature from emitting -- so a live consumer renders nothing instead of rendering "not yet known".
Functions
ofStatic
A fact that is always this value.
GOTCHA: deliberately never completes. Rx.of does, and a completed source defeats Rx.shareReplay -- every subscriber completes, the share drops its upstream, and the next reader re-runs the resolver from scratch. A fact is a live value that happens not to change, not a stream that ended.
startUnresolved
Emits unresolved immediately, then everything the source emits.
unresolvedOnError
Turns a failing source into an unresolved one. A fact whose lookup blew up has not answered, which is exactly what unresolved means -- and one broken mechanism must not fail every feature reading it.
distinctState
RxAccessStateUtils.distinctState() → (Observable<AccessStateUtils.AccessState>) → Observable<AccessStateUtils.AccessState>Suppresses repeats of the same verdict.
Rx.distinct compares by reference and every computed state is a fresh table, so it would suppress nothing. This compares the verdict, via AccessStateUtils.key.
completeOn
Ends the stream when the notifier fires, completing it rather than merely dropping it.
Rx.takeUntil cancels its upstream subscription but never calls Complete, so a consumer is left
holding a stream that has silently stopped -- indistinguishable from one that is simply quiet. A
session ending is something a subscriber needs to be told about, not something it should have to
infer.