• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript form.reducer.factory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中app/store/forms/form.reducer.factory的典型用法代码示例。如果您正苦于以下问题:TypeScript reducer.factory类的具体用法?TypeScript reducer.factory怎么用?TypeScript reducer.factory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了reducer.factory类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: describe

describe('Form reducer factory', () => {

    const config: FormReducerOptions<ExtendedFormState> = {
        show: 'show',
        hide: 'hide',
        toggle: 'toggle',
        request: 'request',
        success: 'success',
        failure: 'failure',
        extras: [{
            types: 'setExtraProp',
            func: (state, action) => assign(state, { extraProp: (action as any).payload })
        }],
        successMessage: 'success!'
    };

    interface ExtendedFormState extends FormState {
        extraProp: any;
    }

    const reducer = formReducer<ExtendedFormState>(config);

    let oldState: ExtendedFormState;

    beforeEach(() => {
        oldState = assignDeep(FormStates.Default as any, { extraProp: 'hello' });
    });

    shouldNotAlterStateOnUnknownAction(reducer);

    it('applies the form visibility WHEN show is called', () => {
        oldState.showForm = false;
        const newState = reducer(oldState, action(config.show as string));
        expect(newState).toEqual(assign(oldState, { showForm: true }));
    });

    it('applies the form visibility WHEN hide is called', () => {
        oldState.showForm = true;
        const newState = reducer(oldState, action(config.hide as string));
        expect(newState).toEqual(assign(oldState, { showForm: false }));
    });

    it('applies the form visibility WHEN toggle is called', () => {
        oldState.showForm = false;
        let newState = reducer(oldState, action(config.toggle as string));
        expect(newState).toEqual(assign(oldState, { showForm: true }));
        newState = reducer(newState, action(config.toggle as string));
        expect(newState).toEqual(assign(oldState, { showForm: false }));
    });

    it('applies the requesting state WHEN request is called', () => {
        const newState = reducer(oldState, action(config.request as string));
        expect(newState).toEqual(assign(oldState, FormStates.Requesting));
    });

    it('applies the success state WHEN success is called', () => {
        const newState = reducer(oldState, action(config.success as string));
        expect(newState).toEqual(assign(oldState, FormStates.Success(config.successMessage)));
    });

    it('applies the failure state WHEN failure is called', () => {
        const newState = reducer(oldState, action(config.failure as string));
        expect(newState).toEqual(assign(oldState, FormStates.Failure(getErrorMessage(undefined))));
    });

    it('Runs custom cases WHEN they are passed', () => {
        const newState = reducer(oldState, action('setExtraProp', '1234'));
        expect(newState).toEqual(assign(oldState, { extraProp: '1234' }));
    });
});
开发者ID:mikule1,项目名称:epool.eu,代码行数:70,代码来源:form.reducer.factory.spec.ts


示例2: resendEmailVerificationReducer

export function resendEmailVerificationReducer(state: FormState,  action: Action) {
    return formReducer({
        request: ResendEmailVerificationActionTypes.Resend,
        failure: ResendEmailVerificationActionTypes.Failure,
        success: ResendEmailVerificationActionTypes.Success,
        successMessage: Messages.ApiResponse.SendVerificationEmailSuccess,
    })(state, action);
}
开发者ID:mikule1,项目名称:epool.eu,代码行数:8,代码来源:resendEmailVerification.reducer.ts


示例3: updateEmailReducer

export function updateEmailReducer(state: FormState, action: Action) {
    return formReducer({
        toggle: UpdateEmailActionTypes.ToggleForm,
        request: UpdateEmailActionTypes.Update,
        success: UpdateEmailActionTypes.Success,
        failure: UpdateEmailActionTypes.Failure,
        successMessage: Messages.ApiResponse.UpdateEmailSuccess,
    })(state, action);
}
开发者ID:mikule1,项目名称:epool.eu,代码行数:9,代码来源:updateEmail.reducer.ts


示例4: resetPasswordFormReducer

export function resetPasswordFormReducer(
    state: FormState,
    action: Action
): FormState {
    return formReducer({
        request: ResetPasswordFormActionTypes.Reset,
        failure: ResetPasswordFormActionTypes.Failure,
        success: ResetPasswordFormActionTypes.Success,
    })(state, action);
}
开发者ID:mikule1,项目名称:epool.eu,代码行数:10,代码来源:resetPasswordForm.reducer.ts


示例5: logInReducer

export function logInReducer(
    state: FormState,
    action: LogInActions.LogInAction
): FormState {
    return formReducer({
        show: LogInActionTypes.ShowModal,
        hide: LogInActionTypes.HideModal,
        request: LogInActionTypes.LogIn,
        success: LogInActionTypes.Success,
        failure: LogInActionTypes.Failure,
    })(state, action);
};
开发者ID:mikule1,项目名称:epool.eu,代码行数:12,代码来源:logIn.reducer.ts


示例6: updatePasswordReducer

export function updatePasswordReducer(
    state: FormState,
    action: Action
): FormState {
    return formReducer({
        toggle: UpdatePasswordActionTypes.ToggleForm,
        request: UpdatePasswordActionTypes.Update,
        failure: UpdatePasswordActionTypes.Failure,
        success: UpdatePasswordActionTypes.Success,
        successMessage: Messages.ApiResponse.UpdatePasswordSuccess,
        failureMessage: Messages.ApiResponse.ServerError,
    })(state, action);
}
开发者ID:mikule1,项目名称:epool.eu,代码行数:13,代码来源:updatePassword.reducer.ts


示例7: signUpFormReducer

export function signUpFormReducer(state: FormState, action: Action): FormState {
    return formReducer({
        request: SignUpFormActionTypes.SignUp,
        failure: SignUpFormActionTypes.Failure,
    })(state, action);
}
开发者ID:mikule1,项目名称:epool.eu,代码行数:6,代码来源:signUpForm.reducer.ts



注:本文中的app/store/forms/form.reducer.factory类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript formState.FormStates类代码示例发布时间:2022-05-25
下一篇:
TypeScript configureStore.store类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap