reduxed 0.0.3
A redux/flux like store in D
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
reduxed
A library implementing the redux pattern in the D Progamming Language.
When should you use reduxed?
The redux pattern helps, when an application has shared state that needs to be observed and manipulated by multiple parts of the application. Additionally, using pure reducer functions makes it easy to test state transitions.
Examples
// Define your store as a struct
struct Bar {
int b;
int a;
}
// Create the store
Store!Bar store;
// set store init values
store.a = 1;
store.b = 2;
int a = 1337;
// We use this function to observe Bar.a
void fun(ref const(int) f) @safe {
a = f;
}
// Here we subscribe to Bar.a
// Whenever Bar.a changes "fun" gets called
store.a.subscribe(&fun);
// This function is used to change the value
static int increment(int a, int b) pure {
return a + b;
}
// Here we call increment with the values of store.a and store.b
// the effect is equal to
// store.a = increment(store.a, store.b);
store.execute!(increment)(store.a, store.b);
assert(store.a.value == 3);
assert(a == 3);
- 0.0.3 released 6 years ago
- burner/reduxed
- LGPL3
- Copyright © 2018, burner
- Authors:
- Dependencies:
- none
- Versions:
-
0.0.3 2018-Aug-23 0.0.2 2018-Aug-21 0.0.1 2018-Aug-21 ~master 2018-Aug-23 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
0 downloads this month
-
9 downloads total
-
- Score:
- 0.6
- Short URL:
- reduxed.dub.pm