Optional
backOptional
cacheIf true (default), stream caches last received value and pushes it to new subscriberswhen they subscribe. If false, calling .deref()
on this stream will always return undefined
.
true
Optional
closeIf false or CloseMode.NEVER
, the stream stays active even if all inputs are done. If true (default) or CloseMode.LAST
, the stream closes when the last input is done. If CloseMode.FIRST
, the instance closes when the first input is done.
CloseMode.LAST
Optional
closeIf false or CloseMode.NEVER
, the stream stays active once there are no more subscribers. If true (default) or CloseMode.LAST
, the stream closes when the last subscriber has unsubscribed. If CloseMode.FIRST
, the instance closes when the first subscriber disconnects.
CloseMode.LAST
Transformation function prepare (e.g. chunk) work for a single worker. Receives worker id
[0 .. numWorkers), numWorkers
and current input value to be processed. Only the results of this function are sent to the worker and therefore the function must return a type compatible with the configured worker instance.
For example, such a function might extract slices from a large input array, one per worker. The given worker ID and worker count can be used to create non-overlapping chunks to evenly spread the workload...
Also see: forkBuffer
Optional
idInternal ID associated with this stream. If omitted, an autogenerated ID will be used.
Optional
interruptIf true, the workers will be terminated and restarted for each new input stream value. This is useful to avoid executing extraneous work and ensures only the most rececent stream value is being processed.
IMPORTANT: Please note that forkJoin
does NOT handle backpressure at all. If interrupt
is false, it's the user's responsibility to ensure that the input stream does NOT operate on a higher frequency than workers can produce results or else undefined behavior WILL occur!
Default: false
Join function. Receives array of worker results (in worker ID order) and is responsible to transform these into the final result / output type.
Optional
numOptional max number of workers to use. Defaults to navigator.hardwareConcurrency
(or if unavailable, then 4 as fallback). If setting this higher, be aware of browser limits and potential resulting crashes!
If using multiple forkJoin
s concurrently, it's the user's responsibility to ensure that the total number of workers won't exceed the browser limit (Chome/FF ~20).
Input stream to attach to obtain work items from.
Optional
terminateIf given and greater than zero, all workers will be terminated after given period (in millis) after the parent stream is done. If used, this value MUST be higher than the expected processing time of the worker jobs, in order to guarantee that the last values are processed fully.
Default: 1000
Optional
transferablesOptional function to extract transferables from fork
result values (i.e. payloads sent to each worker), e.g. ArrayBuffers. See: https://developer.mozilla.org/en-US/docs/Web/API/Worker/postMessage
An existing Worker
instance, a JS source code Blob
or an URL string. In the latter two cases, a worker is created automatically using makeWorker()
.
Generated using TypeDoc
If greater than 0, then each labeled input will cache upto the stated number of input values, even if other inputs have not yet produced new values. Once the limit is reached,
partitionSync()
will throw anIllegalState
error.Enabling this option will cause the same behavior as if
reset
is enabled (regardless of the actual configuredreset
setting). I.e. new results are only produced when ALL required inputs have available values...