Skip to content

Document moment#66

Merged
paldepind merged 1 commit into
masterfrom
document-moment
Jul 6, 2019
Merged

Document moment#66
paldepind merged 1 commit into
masterfrom
document-moment

Conversation

@paldepind
Copy link
Copy Markdown
Member

Related to #64. What do you think @deklanw? Does this make sense?

@funkia funkia deleted a comment from codecov Bot Jun 29, 2019
Copy link
Copy Markdown

@deklanw deklanw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise looks good 👍

Comment thread README.md Outdated
the behaviour and the value of the occurrence, the returned value
becomes the next value of the behavior.

#### `moment<A>(f: (sample: <B>(b: Behavior<B>) => B) => A): Behavior<A>``
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra ` messes up formatting

Comment thread README.md Outdated
```

The above could also be achieved with `lift`. However, `moment` can do many
things that `lift` can't. For instance, `moment` can give better performance
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why better performance?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the question.

If you write something like this:

const lifted = lift((a, b, c, d) => a && b ? c : d, aB, bB, cB, dB);

Then the resulting behavior will always depend on both aB, bB, cB, dB. This means that if any of them changes then the value of lifted will be recomputed. But, clearly we can see that if, for instance, aB is false then the function actually only uses aB and there is no need to recompute lifted if any of the other behaviors changes. However, Hareactive can't know that since the function is just a "black box".

If, on the other hand, we use moment:

const momented = moment((at) => at(aB) && at(bB) ? at(cB) : at(dB));

Then Hareactive can simply check which behaviors are actually sampled inside the function passed to moment, and it uses this information to figure out which behaviors momented depends upon in any given time. This means that when aB is false then Hareactive can figure out that currently momented only depends on atB and there is no need to recompute it when any of the other behaviors changes.

Does that make sense or should I attempt to explain it better? Should I explain it better in the documentation?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That explanation makes sense to me. I think you could put that right into the docs. (Also, the typo above!)

@codecov
Copy link
Copy Markdown

codecov Bot commented Jul 6, 2019

Codecov Report

Merging #66 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #66   +/-   ##
=======================================
  Coverage   95.65%   95.65%           
=======================================
  Files          13       13           
  Lines        1359     1359           
  Branches       60       60           
=======================================
  Hits         1300     1300           
  Misses         59       59

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b962891...c13b033. Read the comment docs.

1 similar comment
@codecov
Copy link
Copy Markdown

codecov Bot commented Jul 6, 2019

Codecov Report

Merging #66 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #66   +/-   ##
=======================================
  Coverage   95.65%   95.65%           
=======================================
  Files          13       13           
  Lines        1359     1359           
  Branches       60       60           
=======================================
  Hits         1300     1300           
  Misses         59       59

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b962891...c13b033. Read the comment docs.

@paldepind
Copy link
Copy Markdown
Member Author

Thanks a lot for the feedback @deklanw 😄 I've updated the PR as you suggested and fixed the typo you caught.

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

Successfully merging this pull request may close these issues.

2 participants