obx 0.1.3 obx: ^0.1.3 copied to clipboard
obx is a elegant state management library.
Obx - Elegant state management library #
Obx is elegant from the name to the way it is used. Its description only needs two screenshots
Feture #
- Obx not need Provider at root Widget.
- Obx use
memo
to intercept update, like react.Hooks. - Obx is tiny and ease use, only 2 API:
ob
,next
Install Obx #
Change pubspec.yaml
:
dependencies:
obx:
Overall interpretation #
Instance a user
,extends Obx
:
// Definition Obx
class User extends Obx {
String name = "dog";
}
// Instance, use some widgets
var user = User();
Subscribe and return a weight:
user.ob(()=>Text(user.name))
Submit and update user.ob's subscribe:
user.next()
Better performance #
Use memo
options params, like React.useMemo
, only rerender data in memo array.
Example only rerender when user.name change:
user.ob(
() => Text(user.name),
memo: ()=>[user.name],
);
Thanks #
That all, keep sample :)