File tree Expand file tree Collapse file tree 3 files changed +36
-6
lines changed Expand file tree Collapse file tree 3 files changed +36
-6
lines changed Original file line number Diff line number Diff line change 2
2
"name" : " react-bus" ,
3
3
"description" : " A global event emitter for react." ,
4
4
"version" : " 2.0.1" ,
5
+ "typings" : " types/index.d.ts" ,
5
6
"author" :
" Renée Kooi <[email protected] >" ,
6
7
"bugs" : {
7
8
"url" : " https://github.com/goto-bus-stop/react-bus/issues"
8
9
},
9
10
"dependencies" : {
10
- "mitt" : " ^1 .1.3 "
11
+ "mitt" : " ^2 .1.0 "
11
12
},
12
13
"peerDependencies" : {
13
- "react" : " >= 16.8 .0"
14
+ "react" : " >=17.0 .0"
14
15
},
15
16
"devDependencies" : {
17
+ "@rollup/plugin-buble" : " ^0.21.3" ,
16
18
"react" : " ^17.0.0" ,
17
19
"react-test-renderer" : " ^17.0.0" ,
18
- "rollup" : " ^2.0.1" ,
19
- "rollup-plugin-buble" : " ^0.19.8" ,
20
- "tape" : " ^5.0.1"
20
+ "rollup" : " ^2.38.0" ,
21
+ "tape" : " ^5.1.1"
21
22
},
22
23
"homepage" : " https://github.com/goto-bus-stop/react-bus#readme" ,
23
24
"keywords" : [
Original file line number Diff line number Diff line change 1
- import buble from 'rollup- plugin-buble'
1
+ import buble from '@ rollup/ plugin-buble'
2
2
3
3
const meta = require ( './package.json' )
4
4
Original file line number Diff line number Diff line change
1
+ import React , { FC , ReactNode } from 'react' ;
2
+ import { Emitter , EventType , Handler } from 'mitt' ;
3
+ export declare const BusContext : React . Context < Emitter | null > ;
4
+ /**
5
+ * Return the event emitter.
6
+ *
7
+ * @export
8
+ * @return {* }
9
+ */
10
+ export declare function useBus ( ) : Emitter ;
11
+ /**
12
+ * Attach an event listener to the bus while this component is mounted. Adds the listener after mount, and removes it before unmount.
13
+ *
14
+ * @export
15
+ * @param {string } name
16
+ * @param {Handler } fn
17
+ */
18
+ export declare function useListener < T = any > ( name : EventType , fn : Handler < T > ) : void ;
19
+ export interface ProviderProps {
20
+ children ?: ReactNode ;
21
+ }
22
+ /**
23
+ * Create an event emitter that will be available to all deeply nested child elements using the useBus() hook.
24
+ *
25
+ * @export
26
+ * @param {ProviderProps } { children }
27
+ * @return {* }
28
+ */
29
+ export declare const Provider : FC < ProviderProps > ;
You can’t perform that action at this time.
0 commit comments