let UseEventSourceReturn {
ready_state,
data,
error,
..
} = use_event_source::<Media, JsonCodec>(
format!("{}/api/media_library/events", client::get_origin()).as_str(),
);
create_effect(move |_| {
log!(ready_state.get());
log!("{:?}", data.get());
log!("{:?}", error.get()); // Signal<Option<UseEventSourceError<JsonCodecError>>> does not implement Clone
});
The hack I came up to fix this (deriving Clone for UseEventSourceError and following the type errors) leads to some undesirable results for FromToStringCodec, because FromStr::Error has no trait bounds and hence no information can be extracted into a Clone-able error type. JsonCodec requires a little work (essentially just copying data from its methods into a new error type) to provide a Clone-able error, but this is not unreasonable.
Simple example:
The hack I came up to fix this (deriving
Clone
forUseEventSourceError
and following the type errors) leads to some undesirable results forFromToStringCodec
, becauseFromStr::Error
has no trait bounds and hence no information can be extracted into a Clone-able error type.JsonCodec
requires a little work (essentially just copying data from its methods into a new error type) to provide a Clone-able error, but this is not unreasonable.