Skip to content

Instantly share code, notes, and snippets.

@hsjunnesson
Last active August 29, 2015 14:01
Show Gist options
  • Select an option

  • Save hsjunnesson/0b3c20d7d9d2de45959e to your computer and use it in GitHub Desktop.

Select an option

Save hsjunnesson/0b3c20d7d9d2de45959e to your computer and use it in GitHub Desktop.

Revisions

  1. hsjunnesson revised this gist May 27, 2014. 1 changed file with 26 additions and 32 deletions.
    58 changes: 26 additions & 32 deletions marbles.md
    Original file line number Diff line number Diff line change
    @@ -6,28 +6,28 @@ A notation for diagramming signals.
    A line signifies time.

    ```
    -------------------------->
    ──────────────────────────>
    ```


    "Marbles" on the line corresponds to "next" events from the signal.

    ```
    ---O-------O-------O------>
    ───O───────O───────O──────>
    ```


    A line at the end of the line corresponds to the "completed" event.

    ```
    -----------O-|
    ───────────O─|
    ```


    An X at the end of the line corresponds to the "error" event.

    ```
    -------------X
    ─────────────X
    ```


    @@ -40,22 +40,21 @@ A UISlider sends its own instance whenever the user moves the slider.

    ```
    slider slider slider
    ---O-------O-------O------>
    ───O───────O───────O───────>
    ```

    We compose a new signal which derives from the original signal and
    maps each next event to the value of the slider at that point.

    ```
    slider slider slider
    ---O-------O-------O------>
    ───O───────O───────O───────>
    | | |
    V V V
    +----------------------+
    +──────────────────────+
    | map: slider -> value |
    +----------------------+
    +──────────────────────+
    | 0.3 | 0.4 | 0.88
    ---O-------O-------O------>
    ───O───────O───────O───────>
    ```

    The new signal, when subscribed to, will send the slider's value as floats.
    @@ -64,48 +63,43 @@ We can further compose the signal - to make it round to the nearest integer, plu

    ```
    slider slider slider
    ---O-------O-------O------>
    ───O───────O───────O───────>
    | | |
    V V V
    +----------------------+
    +──────────────────────+
    | map: slider -> value |
    +----------------------+
    +──────────────────────+
    | 0.3 | 0.4 | 0.88
    ---O-------O-------O------>
    ───O───────O───────O───────>
    | | |
    V V V
    +-----------------------+
    +───────────────────────+
    | map: round(value) + 1 |
    +-----------------------+
    +───────────────────────+
    | 1 | 1 | 2
    ---O-------O-------O------>
    ───O───────O───────O───────>
    ```

    The next step is to make sure the slider only sends whenever there's a change in value.

    ```
    slider slider slider
    ---O-------O-------O------>
    ───O───────O───────O───────>
    | | |
    V V V
    +----------------------+
    +──────────────────────+
    | map: slider -> value |
    +----------------------+
    +──────────────────────+
    | 0.3 | 0.4 | 0.88
    ---O-------O-------O------>
    ───O───────O───────O───────>
    | | |
    V V V
    +-----------------------+
    +───────────────────────+
    | map: round(value) + 1 |
    +-----------------------+
    +───────────────────────+
    | 1 | 1 | 2
    ---O-------O-------O------>
    ───O───────O───────O───────>
    | | |
    V V V
    +----------------------+
    +──────────────────────+
    | distinctUntilChanged |
    +----------------------+
    +──────────────────────+
    | 1 | 2
    ---O---------------O------>
    ───O───────────────O───────>
    ```

  2. hsjunnesson renamed this gist May 27, 2014. 1 changed file with 0 additions and 12 deletions.
    12 changes: 0 additions & 12 deletions gistfile1.md → marbles.md
    Original file line number Diff line number Diff line change
    @@ -6,36 +6,28 @@ A notation for diagramming signals.
    A line signifies time.

    ```
    -------------------------->
    ```


    "Marbles" on the line corresponds to "next" events from the signal.

    ```
    ---O-------O-------O------>
    ```


    A line at the end of the line corresponds to the "completed" event.

    ```
    -----------O-|
    ```


    An X at the end of the line corresponds to the "error" event.

    ```
    -------------X
    ```


    @@ -49,7 +41,6 @@ A UISlider sends its own instance whenever the user moves the slider.
    ```
    slider slider slider
    ---O-------O-------O------>
    ```

    We compose a new signal which derives from the original signal and
    @@ -65,7 +56,6 @@ maps each next event to the value of the slider at that point.
    +----------------------+
    | 0.3 | 0.4 | 0.88
    ---O-------O-------O------>
    ```

    The new signal, when subscribed to, will send the slider's value as floats.
    @@ -89,7 +79,6 @@ We can further compose the signal - to make it round to the nearest integer, plu
    +-----------------------+
    | 1 | 1 | 2
    ---O-------O-------O------>
    ```

    The next step is to make sure the slider only sends whenever there's a change in value.
    @@ -118,6 +107,5 @@ The next step is to make sure the slider only sends whenever there's a change in
    +----------------------+
    | 1 | 2
    ---O---------------O------>
    ```

  3. hsjunnesson created this gist May 27, 2014.
    123 changes: 123 additions & 0 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,123 @@
    Marble diagrams
    ===============

    A notation for diagramming signals.

    A line signifies time.

    ```
    -------------------------->
    ```


    "Marbles" on the line corresponds to "next" events from the signal.

    ```
    ---O-------O-------O------>
    ```


    A line at the end of the line corresponds to the "completed" event.

    ```
    -----------O-|
    ```


    An X at the end of the line corresponds to the "error" event.

    ```
    -------------X
    ```


    Signal composition
    ------------------

    We illustrate signal composition by the following notation.

    A UISlider sends its own instance whenever the user moves the slider.

    ```
    slider slider slider
    ---O-------O-------O------>
    ```

    We compose a new signal which derives from the original signal and
    maps each next event to the value of the slider at that point.

    ```
    slider slider slider
    ---O-------O-------O------>
    | | |
    V V V
    +----------------------+
    | map: slider -> value |
    +----------------------+
    | 0.3 | 0.4 | 0.88
    ---O-------O-------O------>
    ```

    The new signal, when subscribed to, will send the slider's value as floats.

    We can further compose the signal - to make it round to the nearest integer, plus one.

    ```
    slider slider slider
    ---O-------O-------O------>
    | | |
    V V V
    +----------------------+
    | map: slider -> value |
    +----------------------+
    | 0.3 | 0.4 | 0.88
    ---O-------O-------O------>
    | | |
    V V V
    +-----------------------+
    | map: round(value) + 1 |
    +-----------------------+
    | 1 | 1 | 2
    ---O-------O-------O------>
    ```

    The next step is to make sure the slider only sends whenever there's a change in value.

    ```
    slider slider slider
    ---O-------O-------O------>
    | | |
    V V V
    +----------------------+
    | map: slider -> value |
    +----------------------+
    | 0.3 | 0.4 | 0.88
    ---O-------O-------O------>
    | | |
    V V V
    +-----------------------+
    | map: round(value) + 1 |
    +-----------------------+
    | 1 | 1 | 2
    ---O-------O-------O------>
    | | |
    V V V
    +----------------------+
    | distinctUntilChanged |
    +----------------------+
    | 1 | 2
    ---O---------------O------>
    ```