diff --git a/leptos_server/src/resource.rs b/leptos_server/src/resource.rs index 319a2ee6a..1a27e1354 100644 --- a/leptos_server/src/resource.rs +++ b/leptos_server/src/resource.rs @@ -695,6 +695,24 @@ where } } +impl Resource, Ser> +where + Ser: Encoder> + Decoder>, + >>::Error: Debug, + >>::Error: Debug, + <>>::Encoded as FromEncodedStr>::DecodingError: + Debug, + >>::Encoded: IntoEncodedString, + >>::Encoded: FromEncodedStr, + T: Send + Sync + Clone, + E: Send + Sync + Clone, +{ + #[track_caller] + pub fn and_then(&self, f: impl FnOnce(&T) -> U) -> Option> { + self.map(|data| data.as_ref().map(f).map_err(|e| e.clone())) + } +} + impl IntoFuture for Resource where T: Clone + Send + Sync + 'static,