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(callbackfunction) → Observable<Brio>

Creates a new observable wrapping the brio

toBrio

RxBrioUtils.toBrio() → (sourceObservable<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(
brioBrio,
observableObservable<T>
) → Observable<T>

Completes the observable on death

emitWhileAllDead

RxBrioUtils.emitWhileAllDead(valueToEmitWhileAllDeadT) → (sourceObservable<Brio<U>>) → Observable<Brio<U | T>>

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

reduceToAliveList

RxBrioUtils.reduceToAliveList(selectFromBrio((valueT) → U)?) → (sourceObservable<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) → (sourceObservable<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},
filterfunction | 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(valueTBrio) → TProject | Brio<TProject>) → (sourceObservable<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(valueTBrio) → TProject | Brio<TProject>) → (sourceObservable<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 resoruces except the invalidated one.

prepend

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

Prepends the value onto the emitted brio

extend

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

Extends the value onto the emitted brio

map

since 3.6.0
</>
RxBrioUtils.map(projectproject(Brio<T> | T) → Brio<U> | U) → (sourceObservable<Brio<T> | T>) → Observable<Brio<U>>

Maps the input brios to the output observables

mapBrioBrio

since 3.6.0
</>
RxBrioUtils.mapBrioBrio(project(valueTBrio) → 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(
brioBrio<T> | T,
emitOnDeathValueU
) → 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(emitOnDeathValueU) → (brioBrio<T> | T) → Observable<T | U>

Returns a mapping function that emits the given value.

emitOnDeath

RxBrioUtils.emitOnDeath(emitOnDeathValueU) → (sourceObservable<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(sourceObservable<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() → (sourceObservable<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) → (sourceObservable<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(valueTBrio) → TProject,
resultSelector((
initialTBrio,
valueTProject
) → TResult)?
) → (sourceObservable<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(valueTBrio) → TProject) → (sourceObservable<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(valueTBrio) → 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",
            "params": [
                {
                    "name": "callback",
                    "desc": "",
                    "lua_type": "function"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<Brio>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 25,
                "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": 46,
                "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": 62,
                "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": 75,
                "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": 103,
                "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": 187,
                "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": 286,
                "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": 333,
                "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": 364,
                "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": 374,
                "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": 394,
                "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"
                },
                {
                    "name": "resultSelector",
                    "desc": "",
                    "lua_type": "((initial TBrio, value: TProject) -> TResult)?"
                }
            ],
            "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": 413,
                "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": 433,
                "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": 445,
                "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": 465,
                "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 resoruces\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": 489,
                "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": 512,
                "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": 537,
                "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": 553,
                "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": 569,
                "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": 648,
                "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": 673,
                "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": 710,
                "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": 723,
                "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": 737,
                "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": 744,
                "path": "src/brio/src/Shared/RxBrioUtils.lua"
            }
        },
        {
            "name": "switchToBrio",
            "desc": "Switches the result to a brio, and ensures only the last brio lives.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "(source: Observable<T | Brio<T>>) -> Observable<Brio<T>>"
                }
            ],
            "function_type": "static",
            "since": "3.6.0",
            "source": {
                "line": 776,
                "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": 8,
        "path": "src/brio/src/Shared/RxBrioUtils.lua"
    }
}