pinwheel icon indicating copy to clipboard operation
pinwheel copied to clipboard

child_signal_vec unwraps on a None value when the SignalVec is empty

Open broomlytinum opened this issue 3 years ago • 0 comments

I've been working with this version of Pinwheel due to an issue with nested block_ons in child_signal_vec when the child nodes have dynamic components themselves. I'm assuming the usage of now_or_never is to avoid this scenario (or a similar one?).

However, I believe there is an issue with unwrapping the result of now_or_never, as the future will be pending if the SignalVec is empty.

This smaller example demonstrates the panic:

use futures::{future::FutureExt, stream::StreamExt};
use futures_signals::signal_vec::{SignalVecExt, MutableVec};

fn main() {
    let vec = MutableVec::<bool>::new();

    vec.signal_vec()
        .to_stream()
        .next()
        .now_or_never()
        .unwrap();
}

I don't believe there's any need to unwrap it, and any alternative I can think of without unwrapping has the same end result. Though, I'm uneasy with leaving an Option unwrapped like that, so I haven't simply submitted a pull request.

If disallowing zero children in child_signal_vec was an intentional design decision, you may disregard this issue.

broomlytinum avatar May 11 '22 21:05 broomlytinum