DataStream<Data>
A very basic implementation of a data stream with backpressure support which does not use native JS streams or async iterators. This is handy for environments such as React Native which need polyfills for the above.
Extends
BaseObserver
<DataStreamListener
<Data
>>
Type parameters
Type parameter | Value |
---|---|
Data extends any | any |
Constructors
new DataStream()
new DataStream<Data>(options?): DataStream<Data>
Parameters
Parameter | Type |
---|---|
options ? | DataStreamOptions |
Returns
DataStream
<Data
>
Overrides
Properties
Property | Type |
---|---|
dataQueue | Data [] |
Accessors
closed
get closed(): boolean
Returns
boolean
highWatermark
get highWatermark(): number
Returns
number
lowWatermark
get lowWatermark(): number
Returns
number
Methods
close()
close(): Promise<void>
Returns
Promise
<void
>
enqueueData()
enqueueData(data): void
Enqueues data for the consumers to read
Parameters
Parameter | Type |
---|---|
data | Data |
Returns
void
forEach()
forEach(callback): () => void
Executes a callback for each data item in the stream
Parameters
Parameter | Type |
---|---|
callback | DataStreamCallback <Data > |
Returns
Function
Returns
void
iterateAsyncListeners()
iterateAsyncListeners(cb): Promise<void>
Parameters
Parameter | Type |
---|---|
cb | (listener ) => Promise <any > |
Returns
Promise
<void
>
Inherited from
BaseObserver
.iterateAsyncListeners
iterateListeners()
iterateListeners(cb): void
Parameters
Parameter | Type |
---|---|
cb | (listener ) => any |
Returns
void
Inherited from
map()
map<ReturnData>(callback): DataStream<ReturnData>
Creates a new data stream which is a map of the original
Type parameters
Type parameter |
---|
ReturnData |
Parameters
Parameter | Type |
---|---|
callback | (data ) => ReturnData |
Returns
DataStream
<ReturnData
>
read()
read(): Promise<null | Data>
Reads data once from the data stream
Returns
Promise
<null
| Data
>
a Data payload or Null if the stream closed.
registerListener()
registerListener(listener): () => void
Register a listener for updates to the PowerSync client.
Parameters
Parameter | Type |
---|---|
listener | Partial <DataStreamListener <Data >> |
Returns
Function
Returns
void