meowchannel 2.1.2 copy "meowchannel: ^2.1.2" to clipboard
meowchannel: ^2.1.2 copied to clipboard

Simple&Async state manager with middlewares and workers! And yes, you CAN have more than one store in state without depth struggles!

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:meowchannel/extensions/flutter/logger/store_logger_module.dart';
import 'package:meowchannel/meowchannel.dart';

import 'note_list_store/note_list_reducer.dart';
import 'note_list_store/note_list_state.dart';
import 'note_list_store/note_list_worker.dart';

import 'note_application.dart';

void main() => runApp(MaterialApp(
  title: 'Notes!',
  theme: ThemeData(
    primarySwatch: Colors.blue,
  ),

  ///
  /// [MultiStoreProvider] is used to inject [Store] instances into every child widget
  /// Here [NoteListState] store is created with some middlewares (see [storeLogger])
  /// 
  home: MultiStoreProvider(
    providers: [
      StoreProvider<NoteListState>(
        create: (context) =>
          ///
          /// This is [Store]
          /// Oh, wait...
          /// This is 100% similar to Redux Store!
          /// 
          /// Same reducers, same middlewares
          /// Adapted for flutter!
          /// 
          /// Caution: only one Store<StateType> can be present in Provider and its children
          ///
          Store<NoteListState>(
            initialState: NoteListState(noteList: []),
            reducer: noteListReducer,
            modules: [
              ///
              /// [WorkerMiddleware] is a wrapper for a group of workers allowing them to receive actions on one channel
              /// (see [NoteListWorker] and its [NoteListWatcher])
              ///
              workerModule([
                noteListWatcher(noteListWorker)
              ]),
              computedModule<NoteListState>({
                'count': Computed<NoteListState, int>((NoteListState state, int? previousValue) => state.noteList.length)
              }),
              storeLoggerModule('noteListStore')
            ]
          ),
      )
    ],
    child: NoteApplication(),
  ),
));
6
likes
70
pub points
0%
popularity

Publisher

verified publishernk2.eu

Simple&Async state manager with middlewares and workers! And yes, you CAN have more than one store in state without depth struggles!

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

dataclass_beta, flutter, provider, rxdart, uuid

More

Packages that depend on meowchannel