The internal Datatype of the Observable. This is the datatype of the _value
property
Datatype, the setContent
method must receive
Datatype, that will be during forwarding the event data.
The Additional Event-Data, that observers will receive.
Accessor to the currently stored value.
Flag to Disable Publishing of the emitter. This results in not inform the relevant subscriber / observers.
Helper to transform the data using a getter.
Readonly
hasFlag, showing if there exists any subscription this particular observer.
Readonly
idAn id of the Observable. This might be usefull for debugging.
The original Observable. Implemented by an Behaviour Subject. See here: https://www.learnrxjs.io/learn-rxjs/subjects/behaviorsubject for more details.
Readonly
observerReturns the amout of interessed Subscribers / Observers.
options.
Property, a custom setter.
This setter is used to determine, whether the event should be published or not
Therefore it is implemented as callback, which has to return the adpated data
,
and a flag, which shows whether the data
is valid
or not. If the data is
marked es invalid, the event wont be published.
If not required the setter must be set to null
Optional
options: Partial<AD>Function to extract the Content. If a Getter is provided, the getter will be used to Transform the data.
Creates a Subscription for the value of the Event Emitter. After one Update the Subscription will be deleted
Function which is called when new Datas are pushed. The Function must follow the definition in IEventCallback
Optional
options: INopeSubscriptionOptionsAdditional Options used during subscribing INopeSubscriptionOptions
A Function to subscribe to updates of the Event Emitter.
Function which is called when new Datas are pushed. The Function must follow the definition in IEventCallback
Optional
options: INopeSubscriptionOptionsAdditional Options used during subscribing INopeSubscriptionOptions
Async Function to Wait for an Update until the given testCallback
returns true
.
The testCallback
defaultly test for true
Contains the Data, which firstly fullfilled the testCallback
Optional
testCallback: IWaitForCallback<G, AD>Test-Callback which can be implemented async
or sync
. It must return true
to fullfill the promise.
Optional
options: INopeWaitForEventOptionsOptions, to controll the method. (see INopeWaitForEventOptions)
Async Function to Wait for an Update. No specific condition must match. The code will be just awaited until an updat is received.
Optional
options: INopeSubscriptionOptionsAdditional Options for the Wait Function.
Generated using TypeDoc
The Observable extends the INopeEventEmitter.
Instead of the INopeEventEmitter the
Observable
contains persistend data. This results in the following behavior:Contains additional Functionalities like:
Example:
Usage of
nope.observables
To work with
observables
we have to import these:Afterward we are able to create our first Observable.
setContent
: Change the content of the Observable.To change the content of an observable use the method
setContent
.This will print:
setter
: Define a specific setter for the observable.You can specify a specifc getter for the observable for instance, to limit the number to the following constrains
> 0
and< 10
.The setter function will receive multiple parameters, as listed below:
value
,options
containing:sender
: The Element, which changed the datatimestamp
: The timestamp of the changeargs
: additional args.The setter function have to return a
dict
with the following keys:valid
bool
value
any
Below, we will implement an example to show the setter above.
This will print:
Now we can reset the setter by assigning
null
. This disables the setter again:This will print:
To remove such a getter just set the getter property to
null
.getContent
: Get the current content of the Observable.To extract the content of our observable, we are able to use the function
getContent
This will print:
If no data is assigned, this will result in
undefined
. Otherwise the current data is returned.getter
: Define a specific getter for the observable.You can specify a specifc getter for the observable for instance, to allways return a
string
This will print:
To remove such a getter just set the getter property to
null
.The Original value is not changed ==> we expect to get "1337"
This will print:
Subscriptions
You can use an observable to get informed about changes:
callback
, which receives both, the value and the options.subscribe
the observable.During subscribing you can use the following options for subscribing:
skipCurrent
bool
Lets determine the behavior using an example code:
This code results in:
INopeObservable