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

v-stream data is not being updated in componentInstance #106

Closed
MariuszWitkowski opened this issue Apr 25, 2019 · 2 comments
Closed

v-stream data is not being updated in componentInstance #106

MariuszWitkowski opened this issue Apr 25, 2019 · 2 comments

Comments

@MariuszWitkowski
Copy link

MariuszWitkowski commented Apr 25, 2019

v-stream data is not being updated in componentInstance

When i update array rows then my data in v-stream is not updated.

This work

<div v-for="row in rows">
    <input type="checkbox" :id="row.id" v-stream:change="{ subject: change$, data: { id: row.id } }"/>
</div>

This not working

<div v-for="row in rows">
    <Checkbox :id="row.id" v-stream:change="{ subject: change$, data: { id: row.id } }" />
</div>

I think this is problem in directive v-stream:

  ...
  
  bind (el, binding, vnode) {
    ...

    if (!modifiers.native && vnode.componentInstance) {
      ...
    } else {
      ...

      // store handle on element with a unique key for identifying
      // multiple v-stream directives on the same node
      ;(el._rxHandles || (el._rxHandles = {}))[getKey(binding)] = handle
    }
  },
  ...

should be

  ...
  
  bind (el, binding, vnode) {
    ...

    if (!modifiers.native && vnode.componentInstance) {
      ...
    } else {
      ...
    }
    // store handle on element with a unique key for identifying
    // multiple v-stream directives on the same node
    ;(el._rxHandles || (el._rxHandles = {}))[getKey(binding)] = handle
  },
  ...

then data in stream directive is correctly updated on replace rows

@briwa
Copy link
Contributor

briwa commented May 14, 2019

@MariuszWitkowski we were facing the same issue too. Do you mind making a PR for this? That would be great!

@briwa
Copy link
Contributor

briwa commented May 15, 2019

@regou Sorry for reaching out late. You can try it out here https://codesandbox.io/s/m531vow8rx.

  1. Initially, this.foo is 0. If you click the first 4 buttons, it outputs the same thing.
  2. Then, click the button that updates this.foo to a random number.
  3. Click the first 3 buttons, they output the same random number. The last button (custom button with vue-rx) would still output 0.

I saw that you've made a PR for this. Thanks a lot!

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

No branches or pull requests

3 participants