- Wraps a
BehaviorSubjectand stores its current state.
- Can access the current value via
valueto set a new element onto a variable (Don’t use
- Because it wraps a
BehaviorSubjectit is create with an initial value and it will replay its initial value to new subscribers.
- To access a variables
- Guaranteed NOT to emit an error.
- Can listen for error events but cannot add one.
- Will also automatically
completewhen it is about to be deallocated so you do not and cannot manually add
- Like any other subject it can be subscribed to by an observable to be reacted to when a new
.nextevent is emitted.
- Useful for one off needs such as checking the current value without subscribing to receive updates.
var variable = Variable("James Forrest") variable.value = "Scott Brown"
< All Posts