1- import { intercept , Context , Ctrl } from 'js-element'
1+ import { intercept , Ctrl , Ctx } from 'js-element'
22
33// === data ==========================================================
44
@@ -25,18 +25,10 @@ type MessageCreators = {
2525 [ key : string ] : ( ...args : any [ ] ) => Message
2626}
2727
28- type Selectors < S extends State > = {
29- [ key : string ] : ( state : S ) => any
30- }
31-
32- type SelectorsOf < S extends State , U extends Selectors < S > > = {
33- [ K in keyof U ] : U [ K ] extends ( state : S ) => infer R ? R : never
34- }
35-
36- type CtxConfig = Record < string , Context < any > | ( ( ) => any ) >
28+ type CtxConfig = Record < string , Ctx < any > | ( ( ) => any ) >
3729
3830type ResultOfCtxConfig < C extends CtxConfig > = {
39- [ K in keyof C ] : C [ K ] extends Context < infer R >
31+ [ K in keyof C ] : C [ K ] extends Ctx < infer R >
4032 ? R
4133 : C [ K ] extends ( ) => infer R
4234 ? R
@@ -524,7 +516,7 @@ function isEqualArray(arr1: any[], arr2: any[]) {
524516// === context =======================================================
525517
526518type ContextDetail < T > = {
527- context : Context < T >
519+ context : Ctx < T >
528520 callback : ( newValue : T ) => void
529521 cancelled : Promise < null >
530522}
@@ -533,7 +525,7 @@ export const useCtx = hook('useCtx', useCtxFn)
533525
534526function useCtxFn < C extends CtxConfig > ( config : C ) : ResultOfCtxConfig < C >
535527
536- function useCtxFn < T > ( ctx : Context < T > ) : ( ) => T
528+ function useCtxFn < T > ( ctx : Ctx < T > ) : ( ) => T
537529
538530function useCtxFn ( arg : any ) : any {
539531 if ( arg && arg . kind === 'context' ) {
@@ -554,7 +546,7 @@ function useCtxFn(arg: any): any {
554546 return ret
555547}
556548
557- function withConsumer < T > ( ctx : Context < T > ) : ( ) => T {
549+ function withConsumer < T > ( ctx : Ctx < T > ) : ( ) => T {
558550 const c = currentCtrl !
559551 const host = c . getHost ( )
560552 let cancel : null | ( ( ) => void ) = null
0 commit comments