Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a vue binding #161

Open
cefn opened this issue Sep 12, 2021 · 2 comments
Open

Create a vue binding #161

cefn opened this issue Sep 12, 2021 · 2 comments

Comments

@cefn
Copy link
Owner

cefn commented Sep 12, 2021

Should prototype and beta a module e.g. @lauf/store-vue to complement the now-stable @lauf/store-react

It can probably be based on Vue's v1 API since there is a strategy that relies on just created and data. If so, this would effectively 'backport' Immer-based @lauf/store reactivity and framework-independent business logic (and in the long run, time-travel DevTools integration) to any version of Vue.

@cefn cefn added this to To do in Feature Triage Sep 12, 2021
@cefn
Copy link
Owner Author

cefn commented Sep 12, 2021

The fundamental approach is to construct a reactive Vue component that's wired to a @lauf store something like this...

import { createStore } from "@lauf/store"
import { vueOptions } from "@lauf/store-vue";

const store = createStore({counter:0})

const vm = new Vue(
  vueOptions(store, {
    counter:(state) => state.counter
  })
);

This would probably be based on a data which populated named properties from the original selectors, and a create that set up a regular Watcher subscription and which arranged callbacks against the named properties whenever their selected value changed.

See vuejs/vue#214 (comment) for inspiration..

@cefn
Copy link
Owner Author

cefn commented Sep 13, 2021

There is now a draft working implementation at https://github.com/cefn/lauf-vue-gist/blob/main/src/lib/lauf-store-vue.ts

The edit triggered in the counter interval is successfully propagating to a reactive Vue property for each selector.

This needs to have types mapped properly for the Vue library and some other cleanup before beta.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

1 participant