Skip to content

Test: Verify Signal's initialValue laziness #16

@raquo

Description

@raquo

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions