All Projects → ajinasokan → store_keeper

ajinasokan / store_keeper

Licence: MIT license
StoreKeeper is an easy and flexible state management system for Flutter apps

Programming Languages

dart
5743 projects
ruby
36898 projects - #4 most used programming language
swift
15916 projects

Projects that are alternatives of or similar to store keeper

react-nested-loader
The easiest way to manage loaders/errors inside a button. NOT an UI lib.
Stars: ✭ 62 (+181.82%)
Mutual labels:  state-management
vue
Vue integration for Nano Stores, a tiny state manager with many atomic tree-shakable stores
Stars: ✭ 25 (+13.64%)
Mutual labels:  state-management
use-app-state
🌏 useAppState() hook. that global version of setState() built on Context.
Stars: ✭ 65 (+195.45%)
Mutual labels:  state-management
react-cool-form
😎 📋 React hooks for forms state and validation, less code more performant.
Stars: ✭ 246 (+1018.18%)
Mutual labels:  state-management
resynced
An experimental hook that lets you have multiple components using multiple synced states using no context provider
Stars: ✭ 19 (-13.64%)
Mutual labels:  state-management
react-evoke
Straightforward action-driven state management for straightforward apps built with Suspense
Stars: ✭ 15 (-31.82%)
Mutual labels:  state-management
flutter examples
Random flutter examples
Stars: ✭ 18 (-18.18%)
Mutual labels:  state-management
aurelia-hoc-store
An Aurelia application showing the use of higher order components and a single state approach.
Stars: ✭ 20 (-9.09%)
Mutual labels:  state-management
hooksy
Simple app state management based on react hooks
Stars: ✭ 58 (+163.64%)
Mutual labels:  state-management
kstatemachine
KStateMachine is a Kotlin DSL library for creating finite state machines (FSM) and hierarchical state machines (HSM).
Stars: ✭ 63 (+186.36%)
Mutual labels:  state-management
east-store
east-store is a state manager with easiest api that based hooks and immer.
Stars: ✭ 18 (-18.18%)
Mutual labels:  state-management
tacky
Enterprise-level front-end framework based on react
Stars: ✭ 37 (+68.18%)
Mutual labels:  state-management
solid-zustand
🐻 State management in Solid using zustand.
Stars: ✭ 44 (+100%)
Mutual labels:  state-management
redelay
Clojure library for first class lifecycle-managed state.
Stars: ✭ 44 (+100%)
Mutual labels:  state-management
concave
🧐 Lens-like state management (for React).
Stars: ✭ 13 (-40.91%)
Mutual labels:  state-management
flow-state
UI state management with RxJS.
Stars: ✭ 33 (+50%)
Mutual labels:  state-management
react-declarative
A React form builder which interacts with a JSON endpoint to generate nested 12-column grids with input fields and automatic state management in a declarative style. Endpoint is typed by TypeScript guards (IntelliSense available). This tool is based on material-ui components, so your application will look beautiful on any device...
Stars: ✭ 17 (-22.73%)
Mutual labels:  state-management
use-query-string
🆙 A React hook that serializes state into the URL query string
Stars: ✭ 50 (+127.27%)
Mutual labels:  state-management
UseCases
This a library that offers a generic implementation of the data layers from the clean architecture by Uncle bob.
Stars: ✭ 23 (+4.55%)
Mutual labels:  state-management
vue-unstated
A tiny state management library for Vue Composition API.
Stars: ✭ 30 (+36.36%)
Mutual labels:  state-management

StoreKeeper

StoreKeeper is a state management library built for Flutter apps with focus on simplicity. It is heavily inspired by similar libraries in the JavaScript world. Here is a basic idea of how it works:

  • Single Store to keep app's data
  • Structured modifications to store with Mutations
  • Widgets listen to mutations to rebuild themselves
  • Enhance this process with Interceptors and SideEffects

Core of StoreKeeper is based on the InheritedModel widget from Flutter and it was initially developed as the backend for Kite in early 2018. Later it was detached to this library. Now it is in production for numerous other apps including Coin, Olam and Hackly.

Getting started

Add to your pubpsec:

dependencies:
  ...
  store_keeper: ^1.0.0

Create a store:

import 'package:store_keeper/store_keeper.dart';

class AppStore extends Store {
  int count = 0;
}

Define mutations:

class Increment extends Mutation<AppStore> {
  exec() => store.count++;
}

class Multiply extends Mutation<AppStore> {
  final int by;

  Multiply({required this.by});

  exec() => store.count *= by;
}

Listen to mutations:

@override
Widget build(BuildContext context) {
  // Define when this widget should re render
  StoreKeeper.listen(context, to: [Increment, Multiply]);

  // Get access to the store
  final store = StoreKeeper.store as AppStore;

  return Text("${store.count}");
}

Complete example:

import 'package:flutter/material.dart';
import 'package:store_keeper/store_keeper.dart';

// Build store and make it part of app
void main() {
  runApp(StoreKeeper(
    store: AppStore(),
    child: MyApp(),
  ));
}

// Store definition
class AppStore extends Store {
  int count = 0;
}

// Mutations
class Increment extends Mutation<AppStore> {
  exec() => store.count++;
}

class Multiply extends Mutation<AppStore> {
  final int by;

  Multiply({required this.by});

  exec() => store.count *= by;
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // Define when this widget should re render
    StoreKeeper.listen(context, to: [Increment, Multiply]);

    // Get access to the store
    final store = StoreKeeper.store as AppStore;

    return MaterialApp(
      home: Scaffold(
        body: Column(
          children: <Widget>[
            Text("Count: ${store.count}"),
            ElevatedButton(
              child: Text("Increment"),
              onPressed: () {
                // Invoke mutation
                Increment();
              },
            ),
            ElevatedButton(
              child: Text("Multiply"),
              onPressed: () {
                // Invoke with params
                Multiply(by: 2);
              },
            ),
          ],
        ),
      ),
    );
  }
}

Documentation

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].