Skip to content

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

@appsforartists

Description

@appsforartists

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions