-
Notifications
You must be signed in to change notification settings - Fork 8
Examples Operators
Luis Llamas edited this page Aug 24, 2019
·
8 revisions
★ = important
#include "ReactiveArduinoLib.h"
int values[] = { 0, 1, 1, 2, 1, 5, 4 };
size_t valuesLength = sizeof(values) / sizeof(values[0]);
auto observableArray = FromArray<int>(values, valuesLength);
void setup()
{
Serial.begin(9600);
while (!Serial) delay(1);
observableArray
>> Where<int>([](int x) {return x > 2; })
>> ToSerial<int>();
}
void loop()
{
}#include "ReactiveArduinoLib.h"
auto observableInt = FromProperty<int>();
void setup()
{
Serial.begin(9600);
while (!Serial) delay(1);
observableInt
>> Distinct<int>()
>> ToSerial<int>();
}
void loop()
{
delay(1000);
observableInt = 1;
delay(1000);
observableInt = 2;
delay(1000);
observableInt = 2;
delay(1000);
observableInt = 3;
}#include "ReactiveArduinoLib.h"
int values[] = { 0, 1, 1, 2, 1, 5, 4 };
size_t valuesLength = sizeof(values) / sizeof(values[0]);
auto observableArray = FromArray<int>(values, valuesLength);
void setup()
{
Serial.begin(9600);
while (!Serial) delay(1);
observableArray
>> If<int>([](int x) { return x > 2; },
[](int x) {Serial.println(10 * x); })
>> If<int>([](int x) { return x <= 2; },
[](int x) {Serial.println(5 * x); })
>> DoNothing<int>();
}
void loop()
{
}#include "ReactiveArduinoLib.h"
int values[] = { 0, 1, 1, 2, 1, 5, 4 };
size_t valuesLength = sizeof(values) / sizeof(values[0]);
auto observableArray = FromArray<int>(values, valuesLength);
void setup()
{
Serial.begin(9600);
while (!Serial) delay(1);
observableArray
>> ForEach<int>([](int x) {Serial.println(x); })
>> DoNothing<int>();
}
void loop()
{
}#include "ReactiveArduinoLib.h"
int values[] = { 0, 1, 1, 2, 1, 5, 4 };
size_t valuesLength = sizeof(values) / sizeof(values[0]);
auto observableArray = FromArray<int>(values, valuesLength);
void setup()
{
Serial.begin(9600);
while (!Serial) delay(1);
observableArray
>> Repeat<int>(3)
>> ToSerial<int>();
}
void loop()
{
}