@ngrx/effects#ROOT_EFFECTS_INIT TypeScript Examples

The following examples show how to use @ngrx/effects#ROOT_EFFECTS_INIT. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: app.effects.ts    From wingsearch with GNU General Public License v3.0 6 votes vote down vote up
loadLanguage$ = createEffect(() => this.actions$.pipe(
        ofType(ROOT_EFFECTS_INIT, changeLanguage),
        mergeMap((action) => {
            const language = action.language || (this.cookies.hasConsent() && this.cookies.getCookie('language'))
            if (language)
                return from(this.http.get(this.I18N_FOLDER + language + '.json')).pipe(
                    map((data) => ({ type: '[App] Set language', payload: data, language }))
                )
            else
                return of({ type: '[App] English' })
        })
    ))
Example #2
Source File: root.effects.ts    From dating-client with MIT License 5 votes vote down vote up
init$ = createEffect(() =>
    this.actions$.pipe(ofType(ROOT_EFFECTS_INIT), switchMap(() => {
      const localUser = this.local.get('user');
      const user = localUser ? JSON.parse(localUser) : null;
      return of(getUserLocal({ user }));
    }))
  );