This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { Actions, createEffect, ofType } from '@ngrx/effects'; | |
import { map, switchMap } from 'rxjs/operators'; | |
import { doLogin, setLoginStateSuccess, setErrorMessage } from './login.action'; | |
import { LoginService } from '../../services/login/login.service'; | |
@Injectable() | |
export class LoginEffects { | |
setLoginStateSuccess$ = createEffect(() => |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createReducer, on } from '@ngrx/store'; | |
import { setLoginStateSuccess, setErrorMessage } from '../login/login.action'; | |
// ↑↑↑このactionを追加 | |
export interface LoginModel { | |
isLogin: boolean; | |
errorMessage?: string; | |
} | |
export const initialState: LoginModel = { isLogin: false }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createAction, props } from '@ngrx/store'; | |
// ログインするときのactionです、ログインID、パスワードをactionの引数に持ちたい時の書き方 | |
// '[Login] Do Login'は、'[どの画面]どんな処理'のようなイメージです | |
export const doLogin = createAction( | |
'[Login] Do Login', | |
props<{ loginId: string, password: string }>() | |
); | |
// storeのisLoginを更新したい時。更新したい値を引数にする |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createSelector, createFeatureSelector } from '@ngrx/store'; | |
// <{ isLogin: boolean, errorMessage: string }>はstoreの型、reducerに書いたやつ | |
// 'LoginState'はキー。好きな名前でOK | |
export const selectFeature = createFeatureSelector<{ isLogin: boolean, errorMessage: string }>('LoginState'); | |
// getIsLoginというselectorを作成し、storeからisLoginを取得 | |
export const getIsLogin = createSelector( | |
selectFeature, | |
(state) => state.isLogin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface LoginModel { | |
isLogin: boolean; | |
errorMessage?: string; | |
} | |
export const initialState: LoginModel = { isLogin: false }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yarn add @reduxjs/toolkit | |
yarn add redux | |
yarn add @ngrx/store-devtools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ionic capacitor copy ios |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ionic capacitor open ios |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm install -g ios-sim | |
brew install ios-deploy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd ionic-first-app | |
ionic serve |