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

Test: Verify Signal's initialValue laziness #16

Open
raquo opened this issue Dec 22, 2018 · 0 comments
Open

Test: Verify Signal's initialValue laziness #16

raquo opened this issue Dec 22, 2018 · 0 comments

Comments

@raquo
Copy link
Owner

raquo commented Dec 22, 2018

The following code and comment in Signal.scala:

/** Here we need to ensure that Signal's default value has been evaluated.
    * It is important because if a Signal gets started by means of its .changes
    * stream acquiring an observer, nothing else would trigger this evaluation
    * because initialValue is not directly used by the .changes stream.
    * However, when the events start coming in, we will need this initialValue
    * because Signal needs to know when its current value has changed.
    */
  override protected[this] def onStart(): Unit = {
    tryNow() // trigger setCurrentValue if we didn't initialize this before
    super.onStart()
  }

is seemingly inconsistent with the behaviour initial value Failure() when .changes is the only consumer test and the documentation written based on the tested behaviour.

Figure out who is right, and if it's the documentation, figure out why the code isn't doing what it says it's doing. Perhaps the test behaviour is due to the very immediate nature of EventStream.fromSeq?

Also, we need to decide which behaviour is actually desirable, and document our reasons.

  • If we needlessly evaluate initialValue, how do we report errors from it? State needed special treatment for that.
  • If we don't evaluate initialValue, how is that a problem? Make a test that demonstrates the problem.
@raquo raquo changed the title Verify Signal's initialValue laziness Test: Verify Signal's initialValue laziness Dec 22, 2018
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