mrcrowl / vuex-typex

Typescript builder for strongly-typed access to Vuex Store modules
MIT License
193 stars 22 forks source link

Vuex plugins support #1

Closed Lop001 closed 7 years ago

Lop001 commented 7 years ago

It would be great if plugins could be inserted into StoreBuilder.vuexStore()

export interface StoreBuilder<R> {
    /** Get a ModuleBuilder for the namespace provided */
    module<S>(namespace: string, state: S): ModuleBuilder<S, R>;
    /** Output a Vuex Store after all modules have been built */  
    vuexStore(plugins: Array<(store:Store<R>) => void>): Store<R>;
}
mrcrowl commented 7 years ago

Good idea. Included in v1.0.6.

Instead of a plugins argument, I've gone with an optional overrideOptions, which is a partial StoreOptions. i.e.

export interface StoreBuilder<R> {
    /** Get a ModuleBuilder for the namespace provided */
    module<S>(namespace: string, state: S): ModuleBuilder<S, R>;

    /** Output a Vuex Store after all modules have been built */
    vuexStore(): Store<R>

     /** Output a Vuex Store and provide options, e.g. plugins -- these take precedence over any auto-generated options */
    vuexStore(overrideOptions?: StoreOptions<R>): Store<R>;
}
Lop001 commented 7 years ago

It works like a charm. Thank you!