private static bool UnsubscribeAndRemove(ScopeKey key) { if (!keyToSignal.TryGetValue(key, out var e)) { return(false); } e.UnsubscribeAll(); keyToSignal.Remove(key); return(true); }
private static T GetOrCreateSignal <T>(ScopeKey key) where T : SignalBase, new() { if (!keyToSignal.TryGetValue(key, out var e)) { keyToSignal[key] = e = new T { Name = key.Key } } ; return((T)e); }
/// <summary> /// Unsubscribe all callbacks and remove Signal from cache /// </summary> public static bool UnsubscribeAndRemoveSignal <T1, T2>(string scopeKey) { var key = new ScopeKey(typeof(Signal <T1, T2>), scopeKey); return(UnsubscribeAndRemove(key)); }
/// <summary>Get State by Key</summary> public static State <T, TK> State <T, TK>(string scopeKey) { var key = new ScopeKey(typeof(State <T, TK>), scopeKey); return(GetOrCreateSignal <State <T, TK> >(key)); }
/// <summary>Get Signal by Key</summary> public static Signal <T1, T2> Signal <T1, T2>(string scopeKey) { var key = new ScopeKey(typeof(Signal <T1, T2>), scopeKey); return(GetOrCreateSignal <Signal <T1, T2> >(key)); }
/// <summary>Get Signal by Key</summary> public static Signal Signal(string scopeKey) { var key = new ScopeKey(typeof(Signal), scopeKey); return(GetOrCreateSignal <Signal>(key)); }
/// <summary> /// Unsubscribe all callbacks and remove State from cache /// </summary> public static bool UnsubscribeAndRemoveState <T>(string scopeKey) { var key = new ScopeKey(typeof(State <T>), scopeKey); return(UnsubscribeAndRemove(key)); }