mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-13 05:20:25 +00:00
Add definitions for redux-saga-routines (#20481)
This commit is contained in:
committed by
Wesley Wigham
parent
f25fd1c3f6
commit
4ec1572a3d
Vendored
+35
@@ -0,0 +1,35 @@
|
||||
// Type definitions for redux-saga-routines 2.0
|
||||
// Project: https://github.com/afitiskin/redux-saga-routines#readme
|
||||
// Definitions by: Karol Janyst <https://github.com/LKay>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
import { Action } from "redux";
|
||||
import { FormSubmitHandler } from "redux-form";
|
||||
|
||||
export const ROUTINE_PROMISE_ACTION: string;
|
||||
|
||||
export interface RoutineAction<T> extends Action {
|
||||
payload: T;
|
||||
}
|
||||
|
||||
export type RoutineActionCreator<T> = (payload: T) => RoutineAction<T>;
|
||||
|
||||
export interface ReduxRoutine {
|
||||
TRIGGER: string;
|
||||
REQUEST: string;
|
||||
SUCCESS: string;
|
||||
FAILURE: string;
|
||||
FULFILL: string;
|
||||
trigger: RoutineActionCreator<any>;
|
||||
request: RoutineActionCreator<any>;
|
||||
success: RoutineActionCreator<any>;
|
||||
failure: RoutineActionCreator<any>;
|
||||
fulfill: RoutineActionCreator<any>;
|
||||
}
|
||||
|
||||
export function createRoutine(prefix: string): ReduxRoutine;
|
||||
|
||||
export function routinePromiseWatcherSaga(): Iterator<any>;
|
||||
|
||||
export function bindRoutineToReduxForm(routine: ReduxRoutine): FormSubmitHandler;
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"redux": "^3.7.2",
|
||||
"redux-saga": "^0.15.6"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import * as React from "react";
|
||||
import { reduxForm } from "redux-form";
|
||||
import createSagaMiddleware from "redux-saga";
|
||||
import {
|
||||
bindRoutineToReduxForm,
|
||||
createRoutine,
|
||||
routinePromiseWatcherSaga,
|
||||
ROUTINE_PROMISE_ACTION
|
||||
} from "redux-saga-routines";
|
||||
|
||||
const sagaMiddleware = createSagaMiddleware();
|
||||
|
||||
sagaMiddleware.run(routinePromiseWatcherSaga);
|
||||
|
||||
const submitFormRoutine = createRoutine("SUBMIT_MY_FORM");
|
||||
const submitFormHandler = bindRoutineToReduxForm(submitFormRoutine);
|
||||
|
||||
const Test = reduxForm({
|
||||
form : "test"
|
||||
})(
|
||||
({ handleSubmit }) => {
|
||||
return (
|
||||
<form onSubmit={ handleSubmit(submitFormHandler) }>
|
||||
<input type="hidden" name="test" />
|
||||
</form>
|
||||
);
|
||||
}
|
||||
);
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"jsx": "react",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"redux-saga-routines-tests.tsx"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user