Comparing version 0.9.2 to 0.9.3
# Change Log | ||
This project adheres to [Semantic Versioning](http://semver.org/). | ||
## 0.9.3 | ||
* Improved TypeScript support for typed events and store (by @majo44). | ||
## 0.9.2 | ||
@@ -5,0 +8,0 @@ * Fix passing options for Redux DevTools (by Hovhannes Babayan). |
@@ -0,6 +1,9 @@ | ||
type DataTypes<Map, Key extends keyof Map> = | ||
Map extends never ? [any?] : (Map[Key] extends (never | undefined) ? [never?] : [Map[Key]]) | ||
declare namespace createStore { | ||
export type Dispatch<EventsDataTypesMap = any> = <Event extends keyof EventsDataTypesMap>( | ||
event: Event, ...data: (EventsDataTypesMap[Event] extends (never | undefined) ? [never?] : [EventsDataTypesMap[Event]])) => void; | ||
export type Dispatch<EventsDataTypesMap> = (<Event extends keyof EventsDataTypesMap>( | ||
event: Event, ...data: DataTypes<Partial<EventsDataTypesMap>, Event>) => void) & {___events: EventsDataTypesMap}; | ||
export interface Store<State = unknown, EventsDataTypesMap extends StoreonEvents<State> = any> { | ||
export interface Store<State = unknown, EventsDataTypesMap = any> { | ||
readonly on: <Event extends keyof EventsDataTypesMap>( | ||
@@ -14,14 +17,14 @@ event: Event, | ||
export type Module<State, EventsDataTypesMap extends StoreonEvents<State> = any> = (store: Store<State, EventsDataTypesMap>) => void; | ||
export type Module<State, EventsDataTypesMap = any> = (store: Store<State, EventsDataTypesMap>) => void; | ||
export interface StoreonEvents<State> { | ||
'@init': never; | ||
'@changed': Partial<State>; | ||
'@changed': State; | ||
} | ||
} | ||
declare function createStore<State, EventsDataTypesMap extends createStore.StoreonEvents<State> = any>( | ||
modules: Array<createStore.Module<State, EventsDataTypesMap> | false> | ||
): createStore.Store<State, EventsDataTypesMap>; | ||
declare function createStore<State, EventsDataTypesMap = any>( | ||
modules: Array<createStore.Module<State, EventsDataTypesMap> | false> | ||
): createStore.Store<State, EventsDataTypesMap & createStore.StoreonEvents<State>>; | ||
export = createStore; |
{ | ||
"name": "storeon", | ||
"version": "0.9.2", | ||
"version": "0.9.3", | ||
"description": "Tiny (173 bytes) event-based Redux-like state manager for React and Preact", | ||
@@ -17,3 +17,10 @@ "keywords": [ | ||
"./devtools/logger.js": "./devtools/logger.browser.js" | ||
}, | ||
"eslintIgnore": [ | ||
"node_modules", | ||
"test/demo/dist" | ||
], | ||
"sharec": { | ||
"version": "0.3.5" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30204
453