mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-18 04:24:30 +08:00
Added redux-socket.io type (#22773)
* Added redux-socket.io type * Fixed bad dependency on socket.io
This commit is contained in:
committed by
Ryan Cavanaugh
parent
2b8c88b0b6
commit
68e71f0c21
19
types/redux-socket.io/index.d.ts
vendored
Normal file
19
types/redux-socket.io/index.d.ts
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
// Type definitions for redux-socket.io 1.4
|
||||
// Project: https://github.com/itaylor/redux-socket.io#readme
|
||||
// Definitions by: Igor Voropaev <https://github.com/snakeego>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="socket.io-client" />
|
||||
|
||||
import { Middleware, Action, Dispatch } from 'redux';
|
||||
|
||||
export interface MiddlewareOptions {
|
||||
eventName?: string;
|
||||
execute?: <S>(action: Action, emitBound: SocketIOClient.Socket, next: Dispatch<S>, dispatch: Dispatch<S>) => any;
|
||||
}
|
||||
|
||||
export default function createSocketIoMiddleware(
|
||||
socket: SocketIOClient.Socket,
|
||||
criteria: (string | ReadonlyArray<string> | ((type: string, action: Action) => boolean)),
|
||||
options?: MiddlewareOptions
|
||||
): Middleware;
|
||||
6
types/redux-socket.io/package.json
Normal file
6
types/redux-socket.io/package.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"redux": "^3.6.0"
|
||||
}
|
||||
}
|
||||
10
types/redux-socket.io/redux-socket.io-tests.ts
Normal file
10
types/redux-socket.io/redux-socket.io-tests.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import * as ioclient from 'socket.io-client';
|
||||
import createSocketIoMiddleware from 'redux-socket.io';
|
||||
import { Action } from 'redux';
|
||||
|
||||
const socketio = ioclient("test");
|
||||
|
||||
const SocketIOMiddleware1 = createSocketIoMiddleware(socketio, "test");
|
||||
const SocketIOMiddleware2 = createSocketIoMiddleware(socketio, ["test1", "test2"]);
|
||||
const SocketIOMiddleware3 = createSocketIoMiddleware(socketio, (type: string, action: Action) => (type === 'test'));
|
||||
const SocketIOMiddleware4 = createSocketIoMiddleware(socketio, "", { eventName: "test" });
|
||||
23
types/redux-socket.io/tsconfig.json
Normal file
23
types/redux-socket.io/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"redux-socket.io-tests.ts"
|
||||
]
|
||||
}
|
||||
3
types/redux-socket.io/tslint.json
Normal file
3
types/redux-socket.io/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Reference in New Issue
Block a user