Skip to main content

RxBrioUtils

Utility functions involving brios and rx. Brios encapsulate the lifetime of resources, which could be expired by the time a subscription occurs. These functions allow us to manipulate the state of these at a higher order.

Functions​

ofBrio​

RxBrioUtils.ofBrio(callback: ((Maid.Maid) → T) | T) → Observable<Brio<T>>

Creates a new observable wrapping the brio with the brio lasting for the lifetime of the observable

toBrio​

RxBrioUtils.toBrio() → (source: Observable<Brio<T> | T>) → Observable<Brio<T>>

Takes a result and converts it to a brio if it is not one.

of​

RxBrioUtils.of(...: T) → Observable<Brio<T>>

Same as Rx.of but wraps it in a Brio.

completeOnDeath​

RxBrioUtils.completeOnDeath(
brio: Brio,
observable: Observable<T>
) → Observable<T>

Completes the observable on death

emitWhileAllDead​

RxBrioUtils.emitWhileAllDead(valueToEmitWhileAllDead: T) → (source: Observable<Brio<U>>) → Observable<Brio<U | T>>

Whenever all returned brios are dead, emits this value wrapped in a brio.

reduceToAliveList​

RxBrioUtils.reduceToAliveList(selectFromBrio: ((value: T) → U)?) → (source: Observable<Brio<T>>) → Observable<Brio{U}>

This can't be cheap. Consider deeply if you want this or not.

reemitLastBrioOnDeath​

RxBrioUtils.reemitLastBrioOnDeath() → (sourceObservable<Brio<T>>) → Observable<Brio<T>>

Whenever the last brio dies, reemit it as a dead brio

where​

since 3.6.0
</>
RxBrioUtils.where(predicate: (T) → boolean) → (source: Observable<Brio<T>>) → Observable<Brio<T>>

Unpacks the brio, and then repacks it. Ignored items still invalidate the previous brio

flatCombineLatestBrio​

RxBrioUtils.flatCombineLatestBrio(
observables: {[any]: Observable<Brio<T>> | Observable<T> | T},
filter: function | nil
) → Observable<Brio<{[any]: T}>>

Flattens all the brios in one brio and combines them, and then switches it to a brio so only the last state is valid.

flatMapBrio​

since 3.6.0
</>
RxBrioUtils.flatMapBrio(project: (value: TBrio) → TProject | Brio<TProject>) → (source: Observable<Brio<TBrio>> → Observable<Brio<TResult>>)

Flat map equivalent for brios. The resulting observables will be disconnected at the end of the brio.

Like RxBrioUtils.flatMap, but emitted values are wrapped in brios. The lifetime of this brio is limited by the lifetime of the input brios, which are unwrapped and repackaged.

switchMapBrio​

since 3.6.0
</>
RxBrioUtils.switchMapBrio(project: (value: TBrio) → TProject | Brio<TProject>) → (source: Observable<Brio<TBrio>>) → Observable<Brio<TResult>>

Switch map but for brios. The resulting observable will be disconnected on the end of the brio's life.

Like RxBrioUtils.switchMap but emitted values are wrapped in brios. The lifetime of this brio is limited by the lifetime of the input brios, which are unwrapped and repackaged.

flatCombineLatest​

since 3.6.0
</>
RxBrioUtils.flatCombineLatest(observables: {[any]: Observable<Brio<T>> | Observable<T> | T}) → Observable<{[any]: T?}>

Works line combineLatest, but allow the transformation of a brio into an observable that emits the value, and then nil, on death.

The issue here is this:

  1. Resources are found with combineLatest()
  2. One resource dies
  3. All resources are invalidated
  4. We still wanted to be able to use most of the resources

With this method we are able to do this, as we'll re-emit a table with all resources except the invalidated one.

prepend​

since 3.6.0
</>
RxBrioUtils.prepend(...: T) → (source: Observable<Brio<U>>) → Observable<Brio<U | T>>

Prepends the value onto the emitted brio

extend​

since 3.6.0
</>
RxBrioUtils.extend(...: T) → (source: Observable<Brio<U>>) → Observable<Brio<U | T>>

Extends the value onto the emitted brio

map​

since 3.6.0
</>
RxBrioUtils.map(project: project(Brio<T> | T) → Brio<U> | U) → (source: Observable<Brio<T> | T>) → Observable<Brio<U>>

Maps the input brios to the output observables

mapBrioBrio​

since 3.6.0
</>
RxBrioUtils.mapBrioBrio(project: (value: TBrio) → TProject | Brio<TProject>) → (Brio<TBrio>) → Brio<TProject>

Takes in a brio and returns an observable that emits the brio, and then completes on death.

toEmitOnDeathObservable​

RxBrioUtils.toEmitOnDeathObservable(
brio: Brio<T> | T,
emitOnDeathValue: U
) → Observable<T | U>

Transforms the brio into an observable that emits the initial value of the brio, and then another value on death

mapBrioToEmitOnDeathObservable​

RxBrioUtils.mapBrioToEmitOnDeathObservable(emitOnDeathValue: U) → (brio: Brio<T> | T) → Observable<T | U>

Returns a mapping function that emits the given value.

emitOnDeath​

RxBrioUtils.emitOnDeath(emitOnDeathValue: U) → (source: Observable<Brio<T> | T>) → Observable<T | U>

Takes in an observable of brios and returns an observable of the inner values that will also output nil if there is no other value for the brio.

flattenToValueAndNil​

RxBrioUtils.flattenToValueAndNil(source: Observable<Brio<T> | T>) → T | nil

Flattens the observable to nil and the value

onlyLastBrioSurvives​

RxBrioUtils.onlyLastBrioSurvives() → (sourceObservable<Brio<T>>) → Observable<Brio<T>>

Ensures only the last brio survives.

switchToBrio​

since 3.6.0
</>
RxBrioUtils.switchToBrio(predicate: ((T) → boolean)?) → (source: Observable<T | Brio<T>>) → Observable<Brio<T>>

Switches the result to a brio, and ensures only the last brio lives.

filter​

deprecated in 3.6.0
</>
This was deprecated in 3.6.0
This method does not wrap the resulting value in a Brio, which can sometimes lead to leaks.
RxBrioUtils.filter(predicate: (T) → boolean) → (source: Observable<Brio<T>>) → Observable<Brio<T>>

Same as RxBrioUtils.where. Here to keep backwards compatability.

combineLatest​

deprecated in 3.6.0
</>
This was deprecated in 3.6.0
This method does not wrap the resulting value in a Brio, which can sometimes lead to leaks.
RxBrioUtils.combineLatest(observables: {[any]: Observable<Brio<T>> | Observable<T> | T}) → Observable<Brio<{[any]: T}>>

Flattens all the brios in one brio and combines them. Note that this method leads to gaps in the lifetime of the brio.

flatMap​

deprecated in 3.6.0
</>
This was deprecated in 3.6.0
This method does not wrap the resulting value in a Brio, which can sometimes lead to leaks.
RxBrioUtils.flatMap(project: (value: TBrio) → TProject) → (source: Observable<Brio<TBrio>> → Observable<TResult>)

Flat map equivalent for brios. The resulting observables will be disconnected at the end of the brio.

switchMap​

deprecated in 3.6.0
</>
This was deprecated in 3.6.0
This method does not wrap the resulting value in a Brio, which can sometimes lead to leaks.
RxBrioUtils.switchMap(project: (value: TBrio) → TProject) → (source: Observable<Brio<TBrio>>) → Observable<TResult>

Switch map but for brios. The resulting observable will be disconnected on the end of the brio's life.

mapBrio​

deprecated in 3.6.0
</>
This was deprecated in 3.6.0
This method does not wrap the resulting value in a Brio, which can sometimes lead to leaks.
RxBrioUtils.mapBrio(project: (value: TBrio) → TProject) → (brio<TBrio>) → TProject

Takes in a brio and returns an observable that emits the brio, and then completes on death.

Show raw api
{
    "functions": [
        {
            "name": "ofBrio",
            "desc": "Creates a new observable wrapping the brio with the brio lasting for the lifetime of the observable",
            "params": [
                {
                    "name": "callback",
                    "desc": "",
                    "lua_type": "((Maid.Maid) -> T) | T"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<Brio<T>>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 26,
                "path": "src/brio/src/Shared/RxBrioUtils.lua"
            }
        },
        {
            "name": "toBrio",
            "desc": "Takes a result and converts it to a brio if it is not one.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "(source: Observable<Brio<T> | T>) -> Observable<Brio<T>>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 47,
                "path": "src/brio/src/Shared/RxBrioUtils.lua"
            }
        },
        {
            "name": "of",
            "desc": "Same as [Rx.of] but wraps it in a Brio.",
            "params": [
                {
                    "name": "...",
                    "desc": "",
                    "lua_type": "T"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<Brio<T>>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 63,
                "path": "src/brio/src/Shared/RxBrioUtils.lua"
            }
        },
        {
            "name": "completeOnDeath",
            "desc": "Completes the observable on death",
            "params": [
                {
                    "name": "brio",
                    "desc": "",
                    "lua_type": "Brio"
                },
                {
                    "name": "observable",
                    "desc": "",
                    "lua_type": "Observable<T>"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<T>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 76,
                "path": "src/brio/src/Shared/RxBrioUtils.lua"
            }
        },
        {
            "name": "emitWhileAllDead",
            "desc": "Whenever all returned brios are dead, emits this value wrapped\nin a brio.",
            "params": [
                {
                    "name": "valueToEmitWhileAllDead",
                    "desc": "",
                    "lua_type": "T"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "(source: Observable<Brio<U>>) -> Observable<Brio<U | T>>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 107,
                "path": "src/brio/src/Shared/RxBrioUtils.lua"
            }
        },
        {
            "name": "reduceToAliveList",
            "desc": "This can't be cheap. Consider deeply if you want this or not.",
            "params": [
                {
                    "name": "selectFromBrio",
                    "desc": "",
                    "lua_type": "((value: T) -> U)?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "(source: Observable<Brio<T>>) -> Observable<Brio{U}>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 188,
                "path": "src/brio/src/Shared/RxBrioUtils.lua"
            }
        },
        {
            "name": "reemitLastBrioOnDeath",
            "desc": "Whenever the last brio dies, reemit it as a dead brio",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "(source Observable<Brio<T>>) -> Observable<Brio<T>>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 284,
                "path": "src/brio/src/Shared/RxBrioUtils.lua"
            }
        },
        {
            "name": "where",
            "desc": "Unpacks the brio, and then repacks it. Ignored items\nstill invalidate the previous brio",
            "params": [
                {
                    "name": "predicate",
                    "desc": "",
                    "lua_type": "(T) -> boolean"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "(source: Observable<Brio<T>>) -> Observable<Brio<T>>"
                }
            ],
            "function_type": "static",
            "since": "3.6.0",
            "source": {
                "line": 328,
                "path": "src/brio/src/Shared/RxBrioUtils.lua"
            }
        },
        {
            "name": "filter",
            "desc": "Same as [RxBrioUtils.where]. Here to keep backwards compatability.",
            "params": [
                {
                    "name": "predicate",
                    "desc": "",
                    "lua_type": "(T) -> boolean"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "(source: Observable<Brio<T>>) -> Observable<Brio<T>>"
                }
            ],
            "function_type": "static",
            "deprecated": {
                "version": "3.6.0",
                "desc": "This method does not wrap the resulting value in a Brio, which can sometimes lead to leaks."
            },
            "source": {
                "line": 359,
                "path": "src/brio/src/Shared/RxBrioUtils.lua"
            }
        },
        {
            "name": "combineLatest",
            "desc": "Flattens all the brios in one brio and combines them. Note that this method leads to\ngaps in the lifetime of the brio.",
            "params": [
                {
                    "name": "observables",
                    "desc": "",
                    "lua_type": "{ [any]: Observable<Brio<T>> | Observable<T> | T }"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<Brio<{ [any]: T }>>"
                }
            ],
            "function_type": "static",
            "deprecated": {
                "version": "3.6.0",
                "desc": "This method does not wrap the resulting value in a Brio, which can sometimes lead to leaks."
            },
            "source": {
                "line": 369,
                "path": "src/brio/src/Shared/RxBrioUtils.lua"
            }
        },
        {
            "name": "flatCombineLatestBrio",
            "desc": "Flattens all the brios in one brio and combines them, and then switches it to\na brio so only the last state is valid.",
            "params": [
                {
                    "name": "observables",
                    "desc": "",
                    "lua_type": "{ [any]: Observable<Brio<T>> | Observable<T> | T }"
                },
                {
                    "name": "filter",
                    "desc": "",
                    "lua_type": "function | nil"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<Brio<{ [any]: T }>>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 388,
                "path": "src/brio/src/Shared/RxBrioUtils.lua"
            }
        },
        {
            "name": "flatMap",
            "desc": "Flat map equivalent for brios. The resulting observables will\nbe disconnected at the end of the brio.",
            "params": [
                {
                    "name": "project",
                    "desc": "",
                    "lua_type": "(value: TBrio) -> TProject"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "(source: Observable<Brio<TBrio>> -> Observable<TResult>)"
                }
            ],
            "function_type": "static",
            "deprecated": {
                "version": "3.6.0",
                "desc": "This method does not wrap the resulting value in a Brio, which can sometimes lead to leaks."
            },
            "source": {
                "line": 405,
                "path": "src/brio/src/Shared/RxBrioUtils.lua"
            }
        },
        {
            "name": "flatMapBrio",
            "desc": "Flat map equivalent for brios. The resulting observables will\nbe disconnected at the end of the brio.\n\nLike [RxBrioUtils.flatMap], but emitted values are wrapped in brios.\nThe lifetime of this brio is limited by the lifetime of the\ninput brios, which are unwrapped and repackaged.",
            "params": [
                {
                    "name": "project",
                    "desc": "",
                    "lua_type": "(value: TBrio) -> TProject | Brio<TProject>"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "(source: Observable<Brio<TBrio>> -> Observable<Brio<TResult>>)"
                }
            ],
            "function_type": "static",
            "since": "3.6.0",
            "source": {
                "line": 425,
                "path": "src/brio/src/Shared/RxBrioUtils.lua"
            }
        },
        {
            "name": "switchMap",
            "desc": "Switch map but for brios. The resulting observable will be\ndisconnected on the end of the brio's life.",
            "params": [
                {
                    "name": "project",
                    "desc": "",
                    "lua_type": "(value: TBrio) -> TProject"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "(source: Observable<Brio<TBrio>>) -> Observable<TResult>"
                }
            ],
            "function_type": "static",
            "deprecated": {
                "version": "3.6.0",
                "desc": "This method does not wrap the resulting value in a Brio, which can sometimes lead to leaks."
            },
            "source": {
                "line": 437,
                "path": "src/brio/src/Shared/RxBrioUtils.lua"
            }
        },
        {
            "name": "switchMapBrio",
            "desc": "Switch map but for brios. The resulting observable will be\ndisconnected on the end of the brio's life.\n\nLike [RxBrioUtils.switchMap] but emitted values are wrapped in brios.\nThe lifetime of this brio is limited by the lifetime of the\ninput brios, which are unwrapped and repackaged.",
            "params": [
                {
                    "name": "project",
                    "desc": "",
                    "lua_type": "(value: TBrio) -> TProject | Brio<TProject>"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "(source: Observable<Brio<TBrio>>) -> Observable<Brio<TResult>>"
                }
            ],
            "function_type": "static",
            "since": "3.6.0",
            "source": {
                "line": 457,
                "path": "src/brio/src/Shared/RxBrioUtils.lua"
            }
        },
        {
            "name": "flatCombineLatest",
            "desc": "Works line combineLatest, but allow the transformation of a brio into an observable\nthat emits the value, and then nil, on death.\n\nThe issue here is this:\n\n1. Resources are found with combineLatest()\n2. One resource dies\n3. All resources are invalidated\n4. We still wanted to be able to use most of the resources\n\nWith this method we are able to do this, as we'll re-emit a table with all resources\nexcept the invalidated one.",
            "params": [
                {
                    "name": "observables",
                    "desc": "",
                    "lua_type": "{ [any]: Observable<Brio<T>> | Observable<T> | T }"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<{ [any]: T? }>"
                }
            ],
            "function_type": "static",
            "since": "3.6.0",
            "source": {
                "line": 481,
                "path": "src/brio/src/Shared/RxBrioUtils.lua"
            }
        },
        {
            "name": "mapBrio",
            "desc": "Takes in a brio and returns an observable that emits the brio, and then completes\non death.",
            "params": [
                {
                    "name": "project",
                    "desc": "",
                    "lua_type": "(value: TBrio) -> TProject"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "(brio<TBrio>) -> TProject"
                }
            ],
            "function_type": "static",
            "deprecated": {
                "version": "3.6.0",
                "desc": "This method does not wrap the resulting value in a Brio, which can sometimes lead to leaks."
            },
            "source": {
                "line": 504,
                "path": "src/brio/src/Shared/RxBrioUtils.lua"
            }
        },
        {
            "name": "prepend",
            "desc": "Prepends the value onto the emitted brio",
            "params": [
                {
                    "name": "...",
                    "desc": "",
                    "lua_type": "T"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "(source: Observable<Brio<U>>) -> Observable<Brio<U | T>>"
                }
            ],
            "function_type": "static",
            "since": "3.6.0",
            "source": {
                "line": 529,
                "path": "src/brio/src/Shared/RxBrioUtils.lua"
            }
        },
        {
            "name": "extend",
            "desc": "Extends the value onto the emitted brio",
            "params": [
                {
                    "name": "...",
                    "desc": "",
                    "lua_type": "T"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "(source: Observable<Brio<U>>) -> Observable<Brio<U | T>>"
                }
            ],
            "function_type": "static",
            "since": "3.6.0",
            "source": {
                "line": 545,
                "path": "src/brio/src/Shared/RxBrioUtils.lua"
            }
        },
        {
            "name": "map",
            "desc": "Maps the input brios to the output observables",
            "params": [
                {
                    "name": "project",
                    "desc": "",
                    "lua_type": "project (Brio<T> | T) -> Brio<U> | U"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "(source: Observable<Brio<T> | T>) -> Observable<Brio<U>>"
                }
            ],
            "function_type": "static",
            "since": "3.6.0",
            "source": {
                "line": 561,
                "path": "src/brio/src/Shared/RxBrioUtils.lua"
            }
        },
        {
            "name": "mapBrioBrio",
            "desc": "Takes in a brio and returns an observable that emits the brio, and then completes\non death.",
            "params": [
                {
                    "name": "project",
                    "desc": "",
                    "lua_type": "(value: TBrio) -> TProject | Brio<TProject>"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "(Brio<TBrio>) -> Brio<TProject>"
                }
            ],
            "function_type": "static",
            "since": "3.6.0",
            "source": {
                "line": 640,
                "path": "src/brio/src/Shared/RxBrioUtils.lua"
            }
        },
        {
            "name": "toEmitOnDeathObservable",
            "desc": "Transforms the brio into an observable that emits the initial value of the brio, and then another value on death",
            "params": [
                {
                    "name": "brio",
                    "desc": "",
                    "lua_type": "Brio<T> | T"
                },
                {
                    "name": "emitOnDeathValue",
                    "desc": "",
                    "lua_type": "U"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<T | U>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 665,
                "path": "src/brio/src/Shared/RxBrioUtils.lua"
            }
        },
        {
            "name": "mapBrioToEmitOnDeathObservable",
            "desc": "Returns a mapping function that emits the given value.",
            "params": [
                {
                    "name": "emitOnDeathValue",
                    "desc": "",
                    "lua_type": "U"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "(brio: Brio<T> | T) -> Observable<T | U>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 706,
                "path": "src/brio/src/Shared/RxBrioUtils.lua"
            }
        },
        {
            "name": "emitOnDeath",
            "desc": "Takes in an observable of brios and returns an observable of the inner values that will also output\nnil if there is no other value for the brio.",
            "params": [
                {
                    "name": "emitOnDeathValue",
                    "desc": "",
                    "lua_type": "U"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "(source: Observable<Brio<T> | T>) -> Observable<T | U>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 719,
                "path": "src/brio/src/Shared/RxBrioUtils.lua"
            }
        },
        {
            "name": "flattenToValueAndNil",
            "desc": "Flattens the observable to nil and the value",
            "params": [
                {
                    "name": "source",
                    "desc": "",
                    "lua_type": "Observable<Brio<T> | T>"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "T | nil"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 733,
                "path": "src/brio/src/Shared/RxBrioUtils.lua"
            }
        },
        {
            "name": "onlyLastBrioSurvives",
            "desc": "Ensures only the last brio survives.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "(source Observable<Brio<T>>) -> Observable<Brio<T>>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 740,
                "path": "src/brio/src/Shared/RxBrioUtils.lua"
            }
        },
        {
            "name": "switchToBrio",
            "desc": "Switches the result to a brio, and ensures only the last brio lives.",
            "params": [
                {
                    "name": "predicate",
                    "desc": "",
                    "lua_type": "((T) -> boolean)?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "(source: Observable<T | Brio<T>>) -> Observable<Brio<T>>"
                }
            ],
            "function_type": "static",
            "since": "3.6.0",
            "source": {
                "line": 773,
                "path": "src/brio/src/Shared/RxBrioUtils.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "RxBrioUtils",
    "desc": "Utility functions involving brios and rx. Brios encapsulate the lifetime of resources,\nwhich could be expired by the time a subscription occurs. These functions allow us to\nmanipulate the state of these at a higher order.",
    "source": {
        "line": 9,
        "path": "src/brio/src/Shared/RxBrioUtils.lua"
    }
}