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

Stack overflow when the source is the inverse of a sink #251

Open
appsforartists opened this issue Mar 8, 2019 · 0 comments
Open

Stack overflow when the source is the inverse of a sink #251

appsforartists opened this issue Mar 8, 2019 · 0 comments

Comments

@appsforartists
Copy link
Member

This seems like it should work:

    subscribe({
      source: when(
        pointerEvents.up$.rewriteTo({
          value$: thresholdCrossed$,
          onlyEmitWithUpstream: true,
        })
      ).rewriteTo({
        value$: dissolveSpring.destination$.inverted(),
        onlyEmitWithUpstream: true,
      }),
      sink: dissolveSpring.destination$,
    });

to toggle the destination of a spring when a threshold is crossed. dissolveSpring.destination$ is cyclic, but onlyEmitWithUpstream should break the cycle. Nevertheless, it fails with a stack overflow.

Waiting a frame succeeds:

    when(
      pointerEvents.up$.rewriteTo({
        value$: thresholdCrossed$,
        onlyEmitWithUpstream: true,
      })
    ).rewriteTo<number>({
      value$: dissolveSpring.destination$.inverted(),
      onlyEmitWithUpstream: true,
    }).subscribe(
      value => requestAnimationFrame(
        () => dissolveSpring.destination = value
      )
    )

I'm guessing there's a bug in _reactiveMap.

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

1 participant