@logux/vuex
Advanced tools
Comparing version 0.9.11 to 0.9.12
# Change Log | ||
This project adheres to [Semantic Versioning](http://semver.org/). | ||
## 0.9.12 | ||
* Rewrite tests with TypeScript | ||
* Extend `useStore` typings | ||
## 0.9.11 | ||
@@ -5,0 +9,0 @@ * Update Vue to release candidate 11 |
@@ -6,3 +6,3 @@ import { VNodeProps } from 'vue' | ||
Subscribe as SubscribeImpl | ||
} from '..' | ||
} from '../index.js' | ||
@@ -9,0 +9,0 @@ export interface SubscribeProps { |
@@ -7,3 +7,3 @@ import { | ||
import { LoguxVuexStore } from '..' | ||
import { LoguxVuexStore } from '../index.js' | ||
@@ -10,0 +10,0 @@ export type Channel = |
@@ -1,26 +0,4 @@ | ||
import { InjectionKey } from 'vue' | ||
import { LoguxVuexStore } from './store' | ||
/** | ||
* Composable function that injects store into the component. | ||
* | ||
* ```js | ||
* import { useStore } from '@logux/vuex' | ||
* | ||
* export default { | ||
* setup () { | ||
* let store = useStore() | ||
* store.commit.sync('user/rename') | ||
* } | ||
* } | ||
* ``` | ||
* | ||
* @returns Store instance. | ||
*/ | ||
export function useStore<S = any>(injectKey?: InjectionKey<LoguxVuexStore<S>> | string): LoguxVuexStore<S> | ||
export { Client, CrossTabClient } from '@logux/client' | ||
export { Subscribe } from './component' | ||
export { Subscribe } from './component/index.js' | ||
export { | ||
@@ -30,6 +8,7 @@ Channel, | ||
useSubscription | ||
} from './composable' | ||
} from './composable/index.js' | ||
export { | ||
useStore, | ||
LoguxVuexStore, | ||
createStoreCreator | ||
} from './store' | ||
} from './store/index.js' |
{ | ||
"name": "@logux/vuex", | ||
"version": "0.9.11", | ||
"version": "0.9.12", | ||
"description": "Vuex compatible API for Logux", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -0,1 +1,2 @@ | ||
import { InjectionKey } from 'vue' | ||
import { Unsubscribe } from 'nanoevents' | ||
@@ -11,7 +12,8 @@ import { Action, Log } from '@logux/core' | ||
CommitOptions, | ||
Store as VuexStore, | ||
Commit as VuexCommit, | ||
Payload as VuexPayload, | ||
Commit as VuexCommit, | ||
Store as VuexStore, | ||
Dispatch as VuexDispatch, | ||
StoreOptions as VuexStoreOptions, | ||
Dispatch as VuexDispatch | ||
ActionContext as VuexActionContext | ||
} from 'vuex' | ||
@@ -106,5 +108,37 @@ | ||
export class LoguxVuexStore<S = any> extends VuexStore<S> { | ||
constructor (options: VuexStoreOptions<S>) | ||
export interface LoguxVuexActionContext<S, R> extends VuexActionContext<S, R> { | ||
commit: LoguxVuexCommit | ||
} | ||
export type LoguxVuexActionHandler<S, R> = ( | ||
this: LoguxVuexStore<R>, | ||
injectee: LoguxVuexActionContext<S, R>, | ||
payload?: any | ||
) => any | ||
export interface LoguxVuexActionObject<S, R> { | ||
root?: boolean | ||
handler: LoguxVuexActionHandler<S, R> | ||
} | ||
export type LoguxVuexNativeAction<S, R> = | ||
| LoguxVuexActionHandler<S, R> | ||
| LoguxVuexActionObject<S, R> | ||
export interface LoguxVuexActionTree<S, R> { | ||
[key: string]: LoguxVuexNativeAction<S, R> | ||
} | ||
export interface LoguxVuexStoreOptions<S> | ||
extends Omit<VuexStoreOptions<S>, 'actions'> { | ||
actions?: LoguxVuexActionTree<S, S> | ||
} | ||
export class LoguxVuexStore< | ||
S = any, | ||
C extends Client = Client<{}, Log<ClientMeta>>, | ||
L extends Log = Log<ClientMeta> | ||
> extends VuexStore<S> { | ||
constructor (options: LoguxVuexStoreOptions<S>) | ||
dispatch: VuexDispatch | ||
@@ -132,3 +166,3 @@ | ||
*/ | ||
on(event: 'change', listener: StateListener<S>): Unsubscribe | ||
on (event: 'change', listener: StateListener<S>): Unsubscribe | ||
@@ -138,3 +172,3 @@ /** | ||
*/ | ||
client: CrossTabClient | ||
client: C | ||
@@ -144,3 +178,8 @@ /** | ||
*/ | ||
log: Log<ClientMeta> | ||
log: L | ||
/** | ||
* Promise until loading the state from log store. | ||
*/ | ||
initialize: Promise<void> | ||
} | ||
@@ -178,4 +217,7 @@ | ||
*/ | ||
export interface createStore { | ||
<S>(options: VuexStoreOptions<S>): LoguxVuexStore<S> | ||
export interface createStore< | ||
C extends Client = Client<{}, Log<ClientMeta>>, | ||
L extends Log = Log<ClientMeta> | ||
> { | ||
<S>(options: LoguxVuexStoreOptions<S>): LoguxVuexStore<S, C, L> | ||
} | ||
@@ -214,5 +256,30 @@ | ||
*/ | ||
export function createStoreCreator( | ||
export function createStoreCreator< | ||
C extends Client = Client<{}, Log<ClientMeta>>, | ||
L extends Log = Log<ClientMeta> | ||
> ( | ||
client: Client | CrossTabClient, | ||
options?: LoguxVuexOptions | ||
): createStore | ||
): createStore<C, L> | ||
/** | ||
* Composable function that injects store into the component. | ||
* | ||
* ```js | ||
* import { useStore } from '@logux/vuex' | ||
* | ||
* export default { | ||
* setup () { | ||
* let store = useStore() | ||
* store.commit.sync('user/rename') | ||
* } | ||
* } | ||
* ``` | ||
* | ||
* @returns Store instance. | ||
*/ | ||
export function useStore< | ||
S = any, | ||
C extends Client = Client<{}, Log<ClientMeta>>, | ||
L extends Log = Log<ClientMeta> | ||
> (injectKey?: InjectionKey<LoguxVuexStore<S, C, L>> | string): LoguxVuexStore<S, C, L> |
@@ -0,4 +1,4 @@ | ||
import { createStore as createVuexStore } from 'vuex' | ||
import { createNanoEvents } from 'nanoevents' | ||
import { isFirstOlder } from '@logux/core/is-first-older' | ||
import { createStore as createVuexStore } from 'vuex' | ||
import { isFirstOlder } from '@logux/core' | ||
@@ -5,0 +5,0 @@ import { |
Sorry, the diff of this file is not supported yet
55394
1487