-
Notifications
You must be signed in to change notification settings - Fork 2k
/
Copy pathindex.ts
39 lines (35 loc) · 1.04 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
* External dependencies
*/
import { registerStore } from '@wordpress/data';
/**
* Internal dependencies
*/
import { STORE_KEY } from './constants';
import reducer, { State } from './reducer';
import * as actions from './actions';
import * as selectors from './selectors';
import createControls from './controls';
import { DispatchFromMap, SelectFromMap } from '../mapped-types';
import { WpcomClientCredentials } from '../utils';
export * from './types';
export { State };
let isRegistered = false;
export function register( clientCreds: WpcomClientCredentials ): typeof STORE_KEY {
if ( ! isRegistered ) {
const controls = createControls( clientCreds );
isRegistered = true;
registerStore< State >( STORE_KEY, {
actions,
controls: controls as any,
reducer: reducer as any,
resolvers: {},
selectors,
} );
}
return STORE_KEY;
}
declare module '@wordpress/data' {
function dispatch( key: typeof STORE_KEY ): DispatchFromMap< typeof actions >;
function select( key: typeof STORE_KEY ): SelectFromMap< typeof selectors >;
}