ferroui-dynamic-data 0.3.0

A port of DynamicData for FerroUI: reactive collections, change sets, observable caches and lists with their operators, independent of the user interface
Documentation
//! `SubscribeMany` (`Cache/ObservableCacheEx.SubscribeMany.cs`).

macro_rules! subscribe_many_methods {
    () => {
        /// Makes a subscription for each item with `subscription_factory`, when it is added; the
        /// subscription is disposed when the item is removed or replaced, or when the subscription
        /// to the result ends. The change sets are forwarded as they are
        /// (`SubscribeMany(Func<TObject, IDisposable>)`).
        fn subscribe_many(
            &self,
            subscription_factory: impl Fn(&T) -> std::rc::Rc<dyn ferroui_system::IDisposable> + 'static,
        ) -> std::rc::Rc<dyn ferroui_system::IObservable<crate::cache::ChangeSet<T, K>>> {
            crate::cache::internal::subscribe_many(self.change_sets(), std::rc::Rc::new(move |item: &T, _: &K| subscription_factory(item)))
        }

        /// [`subscribe_many`](Self::subscribe_many) with a factory that takes the key
        /// (`SubscribeMany(Func<TObject, TKey, IDisposable>)`).
        fn subscribe_many_with_key(
            &self,
            subscription_factory: impl Fn(&T, &K) -> std::rc::Rc<dyn ferroui_system::IDisposable> + 'static,
        ) -> std::rc::Rc<dyn ferroui_system::IObservable<crate::cache::ChangeSet<T, K>>> {
            crate::cache::internal::subscribe_many(self.change_sets(), std::rc::Rc::new(subscription_factory))
        }
    };
}
pub(crate) use subscribe_many_methods;