Futures_signal :: SignalVec

Quoting: futures_signals::tutorial - Rust

Unlike Signal, it is guaranteed that the SignalVec will never skip a change. In addition, the changes will always be in the correct order.
This is because it is notifying with the difference between the old Vec and the new Vec, so it is very important that it is in the correct order, and that it doesn’t skip anything!

Suppose we have a Vec that goes through three values v0, v1, v2.

There are two interpretations of the sentence above:

  1. we are guaranteed to get diff(v0, v1), diff (v1, v2)

  2. we might get "diff(v0, v1), diff(v1, v2)" or we might just get "diff(v0, v2)"

By the English above, it seems to imply (1); but based on my current understanding of Signal, (2) seems more likely. Can someone familiar with this confirm either way ?

I don’t know this crate, but I looked through that tutorial and the implementation, and it seems like (1) is what’s actually happening; however, the documentation also says

the behavior of exactly which notifications are sent is an implementation detail

so you probably should assume that something like (2), or any other sequence of diffs that produces the same end result, should be possible, too.

Also note that the VecDiff in futures_signals::signal_vec - Rust type doesn’t even support larger diffs, so in most cases the diff(v0, v2) you asked about in interpretation (2) cannot even be represented. Yet. (I’ve read some remark about a VecDiff::Batch variant in the comments, so perhaps that should change at some point.)

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.