Skip to main content

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

RxAccessStateUtils.ofStatic(valueany) → Observable<any>

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

RxAccessStateUtils.startUnresolved() → (Observable<boolean?>) → Observable<boolean?>

Emits unresolved immediately, then everything the source emits.

unresolvedOnError

RxAccessStateUtils.unresolvedOnError() → (Observable<boolean?>) → Observable<boolean?>

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

RxAccessStateUtils.completeOn(notifierObservable) → (Observable<T>) → Observable<T>

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.

Show raw api
{
    "functions": [
        {
            "name": "ofStatic",
            "desc": "A fact that is always this value.\n\nGOTCHA: deliberately never completes. [Rx.of] does, and a completed source defeats [Rx.shareReplay] --\nevery subscriber completes, the share drops its upstream, and the next reader re-runs the resolver from\nscratch. A fact is a live value that happens not to change, not a stream that ended.",
            "params": [
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<any>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 34,
                "path": "src/access/src/Shared/RxAccessStateUtils.lua"
            }
        },
        {
            "name": "startUnresolved",
            "desc": "Emits unresolved immediately, then everything the source emits.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "(Observable<boolean?>) -> Observable<boolean?>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 47,
                "path": "src/access/src/Shared/RxAccessStateUtils.lua"
            }
        },
        {
            "name": "unresolvedOnError",
            "desc": "Turns a failing source into an unresolved one. A fact whose lookup blew up has not answered, which is\nexactly what unresolved means -- and one broken mechanism must not fail every feature reading it.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "(Observable<boolean?>) -> Observable<boolean?>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 63,
                "path": "src/access/src/Shared/RxAccessStateUtils.lua"
            }
        },
        {
            "name": "distinctState",
            "desc": "Suppresses repeats of the same verdict.\n\n[Rx.distinct] compares by reference and every computed state is a fresh table, so it would suppress\nnothing. This compares the verdict, via [AccessStateUtils.key].",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "(Observable<AccessStateUtils.AccessState>) -> Observable<AccessStateUtils.AccessState>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 85,
                "path": "src/access/src/Shared/RxAccessStateUtils.lua"
            }
        },
        {
            "name": "completeOn",
            "desc": "Ends the stream when the notifier fires, completing it rather than merely dropping it.\n\n[Rx.takeUntil] cancels its upstream subscription but never calls `Complete`, so a consumer is left\nholding a stream that has silently stopped -- indistinguishable from one that is simply quiet. A\nsession ending is something a subscriber needs to be told about, not something it should have to\ninfer.",
            "params": [
                {
                    "name": "notifier",
                    "desc": "",
                    "lua_type": "Observable"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "(Observable<T>) -> Observable<T>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 114,
                "path": "src/access/src/Shared/RxAccessStateUtils.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "RxAccessStateUtils",
    "desc": "Observable plumbing for access. The tri-state -- `true | false | nil` -- has to travel through\nobservables like any other value, and none of the obvious [Rx] operators carry `nil`:\n\n* `Rx.startWith({nil})` iterates its list, and a Lua list cannot hold nil, so it fires nothing.\n* `Rx.defaultsTo(nil)` only fires on fail or complete, so a lookup still in flight emits nothing at all.\n* `Rx.of(nil)` relies on varargs packing surviving a lone nil, and completes besides.\n\nThat matters because [Rx.combineLatest] waits for every source to emit once. A fact that stays silent\nuntil its lookup lands would keep the whole feature from emitting -- so a live consumer renders nothing\ninstead of rendering \"not yet known\".",
    "source": {
        "line": 16,
        "path": "src/access/src/Shared/RxAccessStateUtils.lua"
    }
}