vuex#Plugin TypeScript Examples

The following examples show how to use vuex#Plugin. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.ts    From vuex-micro-frontends with MIT License 6 votes vote down vote up
// 监听数据改变
export function receive(keys?: string[]): Plugin<AnyObj> {
  return store => {
    // 监听变化, 设置数据
    iceStore.on(
      VUEX_DATA_KEY,
      (data: AnyObj) => {
        data = pick(data, keys);
        Object.keys(data).forEach((key: string) => {
          store.state[key] = data[key];
        });
      },
      true
    );
  };
}
Example #2
Source File: index.ts    From vuex-micro-frontends with MIT License 5 votes vote down vote up
// 触发数据改变
export function send(keys?: string[]): Plugin<AnyObj> {
  return store => {
    store.subscribe((mutation, state) => {
      iceStore.set(VUEX_DATA_KEY, pick(state, keys));
    });
  };
}
Example #3
Source File: Store.ts    From vuex-orm-next with MIT License 5 votes vote down vote up
/**
 * Install Vuex ORM to the store.
 */
export function install(options?: InstallOptions): Plugin<any> {
  return (store) => {
    mixin(store, createOptions(options))
  }
}