ing
This commit is contained in:
parent
c7a8f0aa3b
commit
07ef70ddad
|
@ -5,7 +5,7 @@ abstract class Service {
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
protected send(methodName: string, params?: string[] | string): Promise<string> {
|
||||
protected send(methodName: string, ...params: any[]): Promise<string> {
|
||||
return new Promise<string>(resolve => {
|
||||
resolve('');
|
||||
});
|
||||
|
@ -13,15 +13,3 @@ abstract class Service {
|
|||
}
|
||||
|
||||
export default Service;
|
||||
|
||||
|
||||
|
||||
export function dService(...methodNames: string[]): Function {
|
||||
return function(owner: any, methodName?: string): void {
|
||||
if (!owner.prototype) {
|
||||
handleActionReducer(owner, methodName);
|
||||
return;
|
||||
}
|
||||
handleRootReducer(owner, methodNames);
|
||||
}
|
||||
}
|
||||
|
|
17
src/ts/commons/context/index.ts
Normal file
17
src/ts/commons/context/index.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
class AppContext {
|
||||
private static context: AppContext;
|
||||
|
||||
private constructor() {
|
||||
|
||||
}
|
||||
|
||||
public static getService<T>(): T {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static getContext(): AppContext {
|
||||
return AppContext.context;
|
||||
}
|
||||
}
|
||||
|
||||
export default AppContext;
|
|
@ -7,9 +7,13 @@ export class MemberService extends Service {
|
|||
super('MemberService');
|
||||
}
|
||||
|
||||
public signin(signinId: string, signinPw: string): Member {
|
||||
this.send('signin');
|
||||
return null;
|
||||
public signin(signinId: string, signinPw: string): Promise<Member> {
|
||||
return new Promise<Member>(resolve => {
|
||||
const json = this.send('signin', [signinId, signinPw]);
|
||||
let member: Member;
|
||||
// member = ........(json);
|
||||
resolve(member);
|
||||
});
|
||||
}
|
||||
|
||||
public signout(member: Member): Member {
|
||||
|
@ -33,3 +37,5 @@ export class MemberService extends Service {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
export default MemberService;
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
import { Action, combineReducers } from 'redux';
|
||||
import { SagaIterator } from 'redux-saga';
|
||||
import { fork, ForkEffect } from 'redux-saga/effects';
|
||||
|
||||
import IModule from 'commons/redux/Module';
|
||||
|
||||
import * as signin from './signin';
|
||||
import * as signout from './signout';
|
||||
import * as signup from './signup';
|
||||
|
||||
export interface State {
|
||||
signin: signin.State;
|
||||
signout: signin.State;
|
||||
signup: signin.State;
|
||||
}
|
||||
|
||||
export const reducer = combineReducers<State>({
|
||||
signin: signin.reducer,
|
||||
signout: signout.reducer,
|
||||
signup: signup.reducer,
|
||||
});
|
||||
|
||||
export function* sagas(): SagaIterator {
|
||||
yield fork(signin.sagas);
|
||||
}
|
|
@ -3,10 +3,10 @@ import {
|
|||
Signin,
|
||||
Props as SigninProps,
|
||||
State as SigninState,
|
||||
} from '../components/Signin';
|
||||
import State from 'member/signin/redux/state';
|
||||
} from './components/Signin';
|
||||
import State from '../redux/state/Signin';
|
||||
|
||||
import signinActions from 'member/signin/redux/action';
|
||||
import signinActions from '../redux/action/signin';
|
||||
|
||||
|
||||
export function mapStateToProps(state: any): SigninProps {
|
||||
|
|
|
@ -12,9 +12,6 @@ export const REQUEST: REQUEST = '@overflow/member/signin/REQUEST';
|
|||
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/member/signin/REQUEST_SUCCESS';
|
||||
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/member/signin/REQUEST_FAILURE';
|
||||
|
||||
export type ActionTypes = REQUEST | REQUEST_SUCCESS | REQUEST_FAILURE;
|
||||
|
||||
|
||||
// Action Creater
|
||||
export type request = (signinId: string, signinPw: string) => Action<SigninPayload>;
|
||||
export type requestSuccess = (member: Member) => Action<Member>;
|
||||
|
|
|
@ -9,9 +9,6 @@ export const REQUEST: REQUEST = '@overflow/member/signout/REQUEST';
|
|||
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/member/signout/REQUEST_SUCCESS';
|
||||
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/member/signout/REQUEST_FAILURE';
|
||||
|
||||
export type ActionTypes = REQUEST | REQUEST_SUCCESS | REQUEST_FAILURE;
|
||||
|
||||
|
||||
// Action Creater
|
||||
export type request = () => Action;
|
||||
export type requestSuccess = () => Action;
|
||||
|
|
|
@ -12,9 +12,6 @@ export const REQUEST: REQUEST = '@overflow/member/signup/REQUEST';
|
|||
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/member/signup/REQUEST_SUCCESS';
|
||||
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/member/signup/REQUEST_FAILURE';
|
||||
|
||||
export type ActionTypes = REQUEST | REQUEST_SUCCESS | REQUEST_FAILURE;
|
||||
|
||||
|
||||
// Action Creater
|
||||
export type request = (member: Member) => Action<Member>;
|
||||
export type requestSuccess = (member: Member) => Action<Member>;
|
||||
|
|
|
@ -1,27 +1,15 @@
|
|||
import { SagaIterator } from 'redux-saga';
|
||||
import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects';
|
||||
|
||||
|
||||
import AppContext from 'commons/context';
|
||||
import Action from 'commons/redux/Action';
|
||||
|
||||
import Member from 'member/api/model/Member';
|
||||
import Member from '../../api/model/Member';
|
||||
import MemberService from '../../api/service/MemberService';
|
||||
import SigninActions from '../action/signin';
|
||||
import SigninPayload from '../payload/SigninPayload';
|
||||
|
||||
const apiSignin = (signinId: string, signinPw: string): Promise<Member> => {
|
||||
return new Promise<Member>(resolve => {
|
||||
setTimeout(() => {
|
||||
let member: Member = {
|
||||
email: 'crusader@loafle.com',
|
||||
name: 'crusader',
|
||||
phone: '02-900-9000',
|
||||
companyName: 'LOAFLE',
|
||||
};
|
||||
|
||||
resolve(member);
|
||||
}, 1000);
|
||||
});
|
||||
};
|
||||
|
||||
function* signin(action: Action<SigninPayload>): SagaIterator {
|
||||
try {
|
||||
const {signinId, signinPw} = action.payload;
|
||||
|
@ -30,7 +18,7 @@ function* signin(action: Action<SigninPayload>): SagaIterator {
|
|||
// payload: {sendingRequest: true},
|
||||
// });
|
||||
|
||||
const member = yield call(apiSignin, signinId, signinPw);
|
||||
const member = yield call(AppContext.getService<MemberService>().signin, signinId, signinPw);
|
||||
|
||||
// if (responseBody.token === undefined) {
|
||||
// throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import Member from 'member/api/model/Member';
|
||||
import Member from '../../api/model/Member';
|
||||
|
||||
export interface State {
|
||||
readonly isAuthenticated: boolean;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import Member from 'member/api/model/Member';
|
||||
import Member from '../../api/model/Member';
|
||||
|
||||
export interface State {
|
||||
readonly isRegistered: boolean;
|
||||
|
|
Loading…
Reference in New Issue
Block a user