Releases
1.6.7
Compare
Sorry, something went wrong.
No results found
allow optional path objects for KeyPaths
this eliminates the need to have non-nullable keys in sub-states that are addressed by KeyStateContext
export type AppExampleState = {
foobar : {
example1 : {
app : { counter : number ; text : string ; } ,
} ,
example2 ?: {
app : { counter : number ; text : string ; } ,
} ,
example3 ?: {
app ?: { counter : number ; text : string ; } ,
} ,
} ,
} ;
const state = createState < AppExampleState > ( {
foobar : {
example1 : {
app : {
counter : 0 ,
text : 'Hello, World!' ,
} ,
} ,
}
} ) ;
const ctx1 = new KeyStateContext < typeof state , { counter : number ; text : string ; } > ( state , "foobar.example1.app" ) ;
const ctx2 = new KeyStateContext < typeof state , { counter : number ; text : string ; } > ( state , "foobar.example2.app" ) ;
const ctx3 = new KeyStateContext < typeof state , { counter : number ; text : string ; } > ( state , "foobar.example3.app" ) ;
in this example foobar.example1.app, foobar.example2.app and foobar.example3.app are the only valid keys
You can’t perform that action at this time.