{"action":"opened","issue":{"url":"https://api.github.com/repos/davidmarne/flutter_built_redux/issues/30","repository_url":"https://api.github.com/repos/davidmarne/flutter_built_redux","labels_url":"https://api.github.com/repos/davidmarne/flutter_built_redux/issues/30/labels{/name}","comments_url":"https://api.github.com/repos/davidmarne/flutter_built_redux/issues/30/comments","events_url":"https://api.github.com/repos/davidmarne/flutter_built_redux/issues/30/events","html_url":"https://github.com/davidmarne/flutter_built_redux/issues/30","id":332323728,"node_id":"MDU6SXNzdWUzMzIzMjM3Mjg=","number":30,"title":"Nested State does not update the UI","user":{"login":"BerndWessels","id":1776695,"node_id":"MDQ6VXNlcjE3NzY2OTU=","avatar_url":"https://avatars2.githubusercontent.com/u/1776695?v=4","gravatar_id":"","url":"https://api.github.com/users/BerndWessels","html_url":"https://github.com/BerndWessels","followers_url":"https://api.github.com/users/BerndWessels/followers","following_url":"https://api.github.com/users/BerndWessels/following{/other_user}","gists_url":"https://api.github.com/users/BerndWessels/gists{/gist_id}","starred_url":"https://api.github.com/users/BerndWessels/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BerndWessels/subscriptions","organizations_url":"https://api.github.com/users/BerndWessels/orgs","repos_url":"https://api.github.com/users/BerndWessels/repos","events_url":"https://api.github.com/users/BerndWessels/events{/privacy}","received_events_url":"https://api.github.com/users/BerndWessels/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-14T09:33:23Z","updated_at":"2018-06-14T09:33:23Z","closed_at":null,"author_association":"NONE","body":"Hi\r\n\r\nI have an AppState and a nested MenuState. \r\nActions on the AppState trigger the reducer and that then triggers the UI to update.\r\nActions on the nested MenuState trigger the nested reducer **BUT do not trigger the UI to update.**\r\n\r\nIs this a bug or am I doing something wrong?\r\n\r\nIf there is nothing obvious in my following code, would you be so kind and provide an example with a nested action and reducer that actually triggers an update using the `flutter_built_redux` `StoreConnection`?\r\n\r\n```\r\nDoctor summary (to see all details, run flutter doctor -v):\r\n[√] Flutter (Channel dev, v0.5.4, on Microsoft Windows [Version 10.0.17134.112], locale en-NZ)\r\n[√] Android toolchain - develop for Android devices (Android SDK 26.0.2)\r\n[√] Android Studio (version 3.1)\r\n[√] IntelliJ IDEA Community Edition (version 2017.3)\r\n```\r\n\r\nstore\r\n```dart\r\nStore<AppState, AppStateBuilder, AppActions> createStore() {\r\n  return new Store<AppState, AppStateBuilder, AppActions>(\r\n    appReducerBuilder.build(),\r\n    new AppState.loading(),\r\n    new AppActions(),\r\n    middleware: [\r\n      createFirebaseMiddleware(),\r\n    ],\r\n  );\r\n}\r\n```\r\n\r\nmiddleware\r\n```dart\r\nfinal Firestore firestore = Firestore.instance;\r\n\r\nMiddleware<AppState, AppStateBuilder, AppActions> createFirebaseMiddleware() {\r\n  return (new MiddlewareBuilder<AppState, AppStateBuilder, AppActions>()\r\n        ..add(AppActionsNames.connectFirestoreAction, connectFirestore))\r\n      .build();\r\n}\r\n\r\nconnectFirestore(MiddlewareApi<AppState, AppStateBuilder, AppActions> api,\r\n    ActionHandler next, Action<Null> action) {\r\n  firestore\r\n      .collection(\"menus/P1N09rgDMAgc5u2KrIIT/items\")\r\n      .orderBy(\"sortOrder\")\r\n      .snapshots()\r\n      .listen((QuerySnapshot snapshot) {\r\n    BuiltList<MenuItem> menuItems =\r\n        documentsToBuiltList<MenuItem>(snapshot.documents, MenuItem.serializer);\r\n    api.actions.menu.menuItemsLoadedSuccessAction(menuItems);\r\n  });\r\n  next(action);\r\n}\r\n```\r\n\r\napp_state\r\n```dart\r\npart 'app_state.g.dart';\r\n\r\nabstract class AppState implements Built<AppState, AppStateBuilder> {\r\n  static Serializer<AppState> get serializer => _$appStateSerializer;\r\n\r\n  factory AppState([updates(AppStateBuilder b)]) = _$AppState;\r\n\r\n  AppState._();\r\n\r\n  BuiltList<Shop> get shops;\r\n\r\n  @nullable\r\n  MenuState get menuState;\r\n```\r\n\r\nmenu_state\r\n```dart\r\npart 'menu_state.g.dart';\r\n\r\nabstract class MenuState implements Built<MenuState, MenuStateBuilder> {\r\n  static Serializer<MenuState> get serializer => _$menuStateSerializer;\r\n\r\n  factory MenuState([updates(MenuStateBuilder b)]) = _$MenuState;\r\n\r\n  MenuState._();\r\n\r\n  @nullable\r\n  String get id;\r\n\r\n  BuiltList<MenuItem> get menuItems;\r\n\r\n  @nullable\r\n  String get title;\r\n}\r\n```\r\n\r\nmenu_item\r\n```dart\r\npart 'menu_item.g.dart';\r\n\r\nabstract class MenuItem implements Built<MenuItem, MenuItemBuilder> {\r\n  static Serializer<MenuItem> get serializer => _$menuItemSerializer;\r\n\r\n  factory MenuItem([updates(MenuItemBuilder b)]) = _$MenuItem;\r\n\r\n  MenuItem._();\r\n\r\n  @nullable\r\n  String get currency;\r\n\r\n  @nullable\r\n  String get description;\r\n\r\n  String get id;\r\n\r\n  @nullable\r\n  double get price;\r\n\r\n  int get sortOrder;\r\n\r\n  String get title;\r\n\r\n  int get type;\r\n}\r\n```\r\n\r\napp_actions\r\n```dart\r\npart 'app_actions.g.dart';\r\n\r\nabstract class AppActions extends ReduxActions {\r\n  ActionDispatcher<Null> connectFirestoreAction;\r\n  ActionDispatcher<BuiltList<Shop>> shopsLoadedSuccessAction;\r\n\r\n  factory AppActions() => new _$AppActions();\r\n\r\n  AppActions._();\r\n\r\n  MenuActions get menu;\r\n}\r\n```\r\n\r\nmenu_actions\r\n```dart\r\npart 'menu_actions.g.dart';\r\n\r\nabstract class MenuActions extends ReduxActions {\r\n  ActionDispatcher<BuiltList<MenuItem>> menuItemsLoadedSuccessAction;\r\n\r\n  factory MenuActions() => new _$MenuActions();\r\n\r\n  MenuActions._();\r\n}\r\n```\r\n\r\napp_reducer\r\n```dart\r\nfinal appReducerBuilder = new ReducerBuilder<AppState, AppStateBuilder>()\r\n  ..add(AppActionsNames.shopsLoadedSuccessAction, shopsLoadedSuccess)\r\n  ..combineNested<MenuState, MenuStateBuilder>(menuReducerBuilder);\r\n```\r\n\r\nmenu_reducer\r\n```dart\r\nfinal menuReducerBuilder =\r\n    new NestedReducerBuilder<AppState, AppStateBuilder, MenuState, MenuStateBuilder>(\r\n        (s) => s.menuState,\r\n        (b) => b.menuState) // maps from the main state object to the nested state\r\n      ..add(MenuActionsNames.menuItemsLoadedSuccessAction, menuItemsLoadedSuccess);\r\n\r\nvoid menuItemsLoadedSuccess(MenuState state, Action<BuiltList<MenuItem>> action,\r\n    MenuStateBuilder builder) {\r\n  builder.menuItems.replace(action.payload);\r\n}\r\n```\r\n\r\nmenu_widget\r\n```dart\r\nclass MenuWidget extends StatefulWidget {\r\n  @override\r\n  MenuWidgetState createState() => MenuWidgetState();\r\n}\r\n\r\nclass MenuWidgetState extends State<MenuWidget>\r\n    with SingleTickerProviderStateMixin {\r\n\r\n// ...\r\n\r\n  @override\r\n  Widget build(BuildContext context) {\r\n    return StoreConnection<AppState, AppActions, BuiltList<MenuItem>>(\r\n        connect: (state) => state.menuState.menuItems,\r\n        builder: (BuildContext context, BuiltList<MenuItem> menuItems,\r\n            AppActions actions) {\r\n          print(menuItems); // not printed when nested action triggers nested reducer :(\r\n          return Scaffold(\r\n\r\n// ...\r\n\r\n            floatingActionButton: FloatingActionButton(\r\n              child: Icon(Icons.control_point),\r\n              onPressed: () {\r\n                actions.connectFirestoreAction();\r\n              },\r\n            ),\r\n\r\n// ...\r\n```"}}
{"actor":{"display_login":"BerndWessels"}}