Download the PHP package miquido/observable without Composer
On this page you can find all versions of the php package miquido/observable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download miquido/observable
More information about miquido/observable
Files in miquido/observable
Package observable
Short Description Observable library
License MIT
Homepage https://github.com/miquido/observable
Informations about the package observable
Observable
Set of classes for data streams.
- Installation guide
- Code Samples
- Contributing
Installation
Use Composer to install the package:
Code Samples
- Create and subscribe to a data stream
- Manipulate data in a stream with Operators
- Using a Subject
- List of build-in operators
Please also check miquido/csv-file-reader library for more real-life examples.
Create and subscribe to a data stream
You can start with simple Miquido\Observable\Stream\FromArray::create method.
Manipulate data in a stream with Operators
Operators can be useful when you want to process the data in the stream before notifying observers. Operators do not interfere with source stream, every operator returns new stream that can be subscribed independently.
You can also add multiple pipes:
Using a Subject
Subject acts both as an observer and as an observable. See an example below:
List of build-in operators
- ArrayCount
- BufferCount
- BufferUniqueCount
- Count
- Filter
- Flat
- Flat
- Reduce
- Scan
- Sum
ArrayCount operator
Transforms array item to number with count value.
BufferCount operator
Groups individual items into an array of provided size.
BufferUniqueCount operator
Similar to BufferCount, but removes duplications.
Count operator
Count all items emitted into the stream.
Filter operator
Removes all values for which provided callback returns false.
Flat operator
If item in a stream is an array, Flat converts this array into set of individual items.
Let operator
Does nothing, do the stream, just fires provided callback for every item in the stream and returns unchanged value.
Map operator
Transform each item in the stream into new value.
Reduce operator
Scan operator
Like Reduce, but observer receives a value after each Scan call.
Sum operator
Sums all items in the stream.
Contributing
Pull requests, bug fixes and issue reports are welcome. Before proposing a change, please discuss your change by raising an issue.