File tree 1 file changed +15
-7
lines changed
1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -3,11 +3,19 @@ import _ from "underscore";
3
3
4
4
import * as allContextProviders from "./providers" ;
5
5
6
- _ . map ( allContextProviders , ( instance , name ) =>
7
- clsInstance . addProvider ( {
8
- instance,
9
- name,
10
- } ) ,
11
- ) ;
6
+ /** Create registry of context providers
7
+ *
8
+ * @summary : Adds context providers to registry and patches them with a static
9
+ * class variable if classes are provided with `classesToPatch`.
10
+ */
11
+ export const createRegistry = ( classesToPatch = [ ] ) => {
12
+ return _ . map ( allContextProviders , ( instance , name ) => {
13
+ classesToPatch . forEach ( ( cls ) => ( instance [ cls . name ] = cls ) ) ;
14
+ return clsInstance . addProvider ( {
15
+ instance,
16
+ name,
17
+ } ) ;
18
+ } ) ;
19
+ } ;
12
20
13
- export const ContextProviderRegistry = clsInstance ;
21
+ export const ContextProviderRegistry = createRegistry ( ) ;
You can’t perform that action at this time.
0 commit comments