pub fn create_provider<T: resources::Resource + Clone + PartialEq>(&mut self, initial_state: T) -> Binding<T> {
        let type_id = initial_state.type_id();

        let providers = self.widget_providers.entry(type_id.clone()).or_insert(HashMap::default());

        if let Some(provider) = providers.get(&self.current_id) {
            if let Ok(state) = provider.get::<Binding<T>>() {
                // Provider was already created
                return state.clone();
            }
        }

        let mut provider = resources::Resources::default();
        let state = crate::bind(initial_state);
        let lifetime = Self::create_lifetime(&state, &self.widget_manager, self.current_id);
        Self::insert_state_lifetime(
            &mut self.widget_state_lifetimes,
            self.current_id,
            state.id,
            lifetime,
        );
        provider.insert(state.clone());
        providers.insert(self.current_id, provider);

        state
    }
/// Creates a provider context with the given state data
///
/// This works much like [create_state](Self::create_state), except that the state is also made available to any children. They can
/// access this provider's state by calling [create_consumer](Self::create_consumer).
Creates a provider context with the given state data
This works much like [create_state](Self::create_state), except that the state is also made available to any children. They can
access this provider's state by calling [create_consumer](Self::create_consumer).
Creates a provider context with the given state data This works much like [ create_state ] ( Self :: create_state ) except that the state is also made available to any children . They can access this provider ' s state by calling [ create_consumer ] ( Self :: create_consumer ) .
pub fn create_provider<T: resources::Resource + Clone + PartialEq>(&mut self, initial_state: T) -> Binding<T> {
        let type_id = initial_state.type_id();
        let providers = self.widget_providers.entry(type_id.clone()).or_insert(HashMap::default());
        if let Some(provider) = providers.get(&self.current_id) {
            if let Ok(state) = provider.get::<Binding<T>>() {
                // Provider was already created
                return state.clone();
            }
        }
        let mut provider = resources::Resources::default();
        let state = crate::bind(initial_state);
        let lifetime = Self::create_lifetime(&state, &self.widget_manager, self.current_id);
        Self::insert_state_lifetime(
            &mut self.widget_state_lifetimes,
            self.current_id,
            state.id,
            lifetime,
        );
        provider.insert(state.clone());
        providers.insert(self.current_id, provider);
        state
    }
pub fn create_provider < T : resources :: Resource + Clone + PartialEq > ( & mut self , initial_state : T ) -> Binding < T > { let type_id = initial_state . type_id ( ) ; let providers = self . widget_providers . entry ( type_id . clone ( ) ) . or_insert ( HashMap :: default ( ) ) ; if let Some ( provider ) = providers . get ( & self . current_id ) { if let Ok ( state ) = provider . get :: < Binding < T > > ( ) { // Provider was already created return state . clone ( ) ; } } let mut provider = resources :: Resources :: default ( ) ; let state = crate :: bind ( initial_state ) ; let lifetime = Self :: create_lifetime ( & state , & self . widget_manager , self . current_id ) ; Self :: insert_state_lifetime ( & mut self . widget_state_lifetimes , self . current_id , state . id , lifetime , ) ; provider . insert ( state . clone ( ) ) ; providers . insert ( self . current_id , provider ) ; state }
Creates a provider context with the given state data
This works much like [create_state](Self::create_state), except that the state is also made available to any children.
Creates a provider context with the given state data This works much like [ create_state ] ( Self :: create_state ) except that the state is also made available to any children .
&mut self
initial_state
T
&mut self
initial_state
T