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

Bug when stream can emit nulls #1

Open
theadam opened this issue Jul 21, 2016 · 2 comments
Open

Bug when stream can emit nulls #1

theadam opened this issue Jul 21, 2016 · 2 comments

Comments

@theadam
Copy link

theadam commented Jul 21, 2016

See attached code:
https://esnextb.in/?gist=0417b9e27e3ef0ad1111c88149d53a7c

@xialvjun
Copy link
Owner

I've changed the ReactiveClass render method with:
return children instanceof VNode ? h(children.nodeName, {...children.attributes, props}, ...children.children) : children....
That should work, and in fact, it indeed works on the new counter example ({ count$.map(c => c % 2 === 1 ? c+'' : null) }), but it doesn't work on the map_to_a_list$ example... That's weird.....
I doubt if it's preact's bug...... Or if only there are more documents on preact.

@xialvjun
Copy link
Owner

Well, a stream can emit everything at every time, but self control element just want a valid element (preact can accept a string, but react just accept a valid element... )

If I remove self control element and all is parent control element, then it will consume some more.

And since children is just a prop of props, but I change the total children to a stream just because one of the children is a stream, then should I change the total of a prop to a stream just because some inner prop of the prop is a stream? ... I don't know...

Maybe the best way is just remove the concept of self control element, and tell people be aware of the consume of parent control element with more document...

function wrapChildren(children) {
  const streamElement$s = children.filter(child => isStream(child))
  if (streamElement$s.length > 0) {
    return combine(() => {
      return children.map(child => {
        if (!isStream(child)) {
          return child
        }
        if (streamElement$s.indexOf(child) > -1) {
          return child()
        }
        return preactH(reactive(), {children$: child})
      })
    }, streamElement$s)
  }
  return children
}

I really don't know which is the best... Hoping at some time, the react like library can return some more type like string, array, null...

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

2 participants