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
Creates a new observable wrapping the brio
toBrio
Takes a result and converts it to a brio if it is not one.
of
Same as Rx.of but wraps it in a Brio.
completeOnDeath
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
Whenever the last brio dies, reemit it as a dead brio
where
Unpacks the brio, and then repacks it. Ignored items still invalidate the previous brio
flatCombineLatestBrio
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
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
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
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:
- Resources are found with combineLatest()
- One resource dies
- All resources are invalidated
- 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
Prepends the value onto the emitted brio
extend
Extends the value onto the emitted brio
map
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
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
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
Flattens the observable to nil and the value
onlyLastBrioSurvives
Ensures only the last brio survives.
switchToBrio
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
This was deprecated in 3.6.0
This method does not wrap the resulting value in a Brio, which can sometimes lead to leaks.
Same as RxBrioUtils.where. Here to keep backwards compatability.
combineLatest
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
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
,
resultSelector:
(
(
initial
TBrio
,
value:
TProject
)
→
TResult
)
?
) →
(
source:
Observable
<
Brio
<
TBrio
>
>
→
Observable
<
TResult
>
)
Flat map equivalent for brios. The resulting observables will be disconnected at the end of the brio.
switchMap
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
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.