mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 23:07:06 +00:00
Add react-broadcast definition
This commit is contained in:
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
// Type definitions for react-broadcast 0.6
|
||||
// Project: https://github.com/ReactTraining/react-broadcast
|
||||
// Definitions by: Jaga Santagostino <https://github.com/kandros>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
import * as React from 'react';
|
||||
|
||||
export namespace Subscriber {
|
||||
interface DefaultProps {
|
||||
quiet: boolean;
|
||||
}
|
||||
interface Props<T> extends Partial<DefaultProps> {
|
||||
channel: string;
|
||||
children?: ((state: T) => React.ReactNode);
|
||||
}
|
||||
}
|
||||
|
||||
export namespace Broadcast {
|
||||
interface DefaultProps<T> {
|
||||
compareValues: (prevValue: T, nextValue: T) => boolean;
|
||||
}
|
||||
interface Props<T> extends Partial<DefaultProps<T>> {
|
||||
channel: string;
|
||||
children: React.ReactNode;
|
||||
value: T;
|
||||
}
|
||||
}
|
||||
|
||||
export class Broadcast<T> extends React.Component<Broadcast.Props<T>, any> { }
|
||||
export class Subscriber<T> extends React.Component<Subscriber.Props<T>, any> { }
|
||||
@@ -0,0 +1,17 @@
|
||||
import * as React from 'react';
|
||||
import { Broadcast, Subscriber } from 'react-broadcast';
|
||||
|
||||
class ExampleOfUsingReactBroadcast extends React.Component {
|
||||
render() {
|
||||
const value = 42;
|
||||
return (
|
||||
<Broadcast channel="my-channel" value={42}>
|
||||
<div>
|
||||
<Subscriber channel="my-channel">
|
||||
{state => <div>{state}</div>}
|
||||
</Subscriber>
|
||||
</div>
|
||||
</Broadcast>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"module": "commonjs",
|
||||
"lib": ["es6", "dom"],
|
||||
"jsx": "react",
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": false,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noEmit": true
|
||||
},
|
||||
"files": ["index.d.ts", "react-broadcast-tests.tsx"]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Reference in New Issue
Block a user