{"action":"created","issue":{"url":"https://api.github.com/repos/ngrx/effects/issues/87","repository_url":"https://api.github.com/repos/ngrx/effects","labels_url":"https://api.github.com/repos/ngrx/effects/issues/87/labels{/name}","comments_url":"https://api.github.com/repos/ngrx/effects/issues/87/comments","events_url":"https://api.github.com/repos/ngrx/effects/issues/87/events","html_url":"https://github.com/ngrx/effects/issues/87","id":198932285,"number":87,"title":"Cannot process the same action from 2 different effects","user":{"login":"DxCx","id":1080411,"avatar_url":"https://avatars.githubusercontent.com/u/1080411?v=3","gravatar_id":"","url":"https://api.github.com/users/DxCx","html_url":"https://github.com/DxCx","followers_url":"https://api.github.com/users/DxCx/followers","following_url":"https://api.github.com/users/DxCx/following{/other_user}","gists_url":"https://api.github.com/users/DxCx/gists{/gist_id}","starred_url":"https://api.github.com/users/DxCx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DxCx/subscriptions","organizations_url":"https://api.github.com/users/DxCx/orgs","repos_url":"https://api.github.com/users/DxCx/repos","events_url":"https://api.github.com/users/DxCx/events{/privacy}","received_events_url":"https://api.github.com/users/DxCx/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2017-01-05T11:16:40Z","updated_at":"2017-01-22T09:39:25Z","closed_at":null,"body":"Hi,\r\n\r\nI'm trying to use Dispatcher.INIT action, to do some effects init,\r\ni have couple of modules that should process it, but looks like it is trapped.\r\n(Only 1 module will process it, if i remove it from NgModule, only the next will process, etc..)\r\n\r\nso it looks something like this:\r\napp.module.ts\r\n```typescript\r\n@NgModule({\r\n    ....\r\n    imports: [\r\n      EffectsModule.run(ModuleAEffects),\r\n      EffectsModule.run(ModuleBEffects),\r\n    ],\r\n    ....\r\n})\r\nexport class AppModule {};\r\n```\r\n\r\nthen each module Effects class will have a simple pipe of:\r\nmodule<x>.effects.ts\r\n```typescript\r\n@Effect() init$ =\r\nthis.actions$.ofType(Dispatcher.INIT)\r\n  .switchMap(() => {\r\n      // DO INIT FOR MODULE\r\n  });\r\n```\r\n\r\nand as i mentioned above, only the first one registered on NgModule is being processed,\r\nthe other does not.\r\n\r\nthen, i said to myself, let's try to split the 1 trapped init event, into 2 events (or more in the future)\r\nso i resulted creating actions of `MODULE_A_INIT`, `MODULE_B_INIT`.\r\nreplace the `ofType` above for each module,\r\nthen created another effect which is registered first and containing:\r\n\r\n```typescript\r\n@Effect() init$ =\r\nthis.actions$.ofType(Dispatcher.INIT)\r\n  .switchMap(() => Observable.of([{\r\n    type: MODULE_A_INIT,\r\n  }, {\r\n    type: MODULE_B_INIT,\r\n  }])\r\n  .concatMap(actions => Observable.from(actions)));\r\n```\r\nNOTE: i tried also with `mergeMap` and `flatMap`\r\n\r\nand with this approach, i can see both actions are fired, however the first _INIT is not being processed, only the lastest action emitted is. (switchMap/withLatestFrom?)\r\n\r\nso, TLDR, how can i process the same action using more then 1 effect?\r\nfor reducers it works, you can process the same action in more then one reducer.."},"comment":{"url":"https://api.github.com/repos/ngrx/effects/issues/comments/274320150","html_url":"https://github.com/ngrx/effects/issues/87#issuecomment-274320150","issue_url":"https://api.github.com/repos/ngrx/effects/issues/87","id":274320150,"user":{"login":"bertofer","id":1634229,"avatar_url":"https://avatars.githubusercontent.com/u/1634229?v=3","gravatar_id":"","url":"https://api.github.com/users/bertofer","html_url":"https://github.com/bertofer","followers_url":"https://api.github.com/users/bertofer/followers","following_url":"https://api.github.com/users/bertofer/following{/other_user}","gists_url":"https://api.github.com/users/bertofer/gists{/gist_id}","starred_url":"https://api.github.com/users/bertofer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bertofer/subscriptions","organizations_url":"https://api.github.com/users/bertofer/orgs","repos_url":"https://api.github.com/users/bertofer/repos","events_url":"https://api.github.com/users/bertofer/events{/privacy}","received_events_url":"https://api.github.com/users/bertofer/received_events","type":"User","site_admin":false},"created_at":"2017-01-22T09:39:25Z","updated_at":"2017-01-22T09:39:25Z","body":"Yes, will be useful as we can try it locally.\r\n\r\nRegarding the recursivity, it can happen. If you don't use @Effect({dispatch: false}) on the logger for instance, it will propagate @ngrx/store/init and it will be dispatched again entering an infinite loop. \r\n\r\nWhat do you mean by `the logger does not catch the events`? Catch how?\r\n\r\nRegarding 1., for now I am using store.dispatch() in the .catch error, because I think ngrx/effects doesn't dispatch when the action comes directly from the catch, I am not sure if this can be a rxjs limitation. I want to investigate more this to open an issue if needed.\r\n\r\nIn 2., what do you mean by events? Actions? Side effects?"}}
{"actor":{"display_login":"bertofer"}}