// You should not write to Val when using RxRef public static RxRef <A> toRxRef <A>(this PrefVal <A> val) { var rx = new RxRef <A>(val.value); rx.subscribe(v => val.value = v); return(rx); }
public void Normal() { Fn <PrefVal <string> > create = () => storage.custom(key, "", PrefVal.stringSerialize, PrefVal.stringDeserialize); var pv = create(); pv.value.shouldEqual(""); pv.value = "foobar"; const string key2 = key + "2"; storage.custom( key2, "", s => Convert.ToBase64String(PrefVal.stringSerialize(s)), _ => Option <string> .None ).value = pv.value; backend.storage[key].shouldEqual(backend.storage[key2]); var pv2 = create(); pv2.value.shouldEqual(pv.value); }
public static ICachedBlob <A> optToCachedBlob <A>( this PrefVal <Option <A> > val ) => new PrefValOptCachedBlob <A>(val);
public static PrefVal <B> bimap <A, B>( this PrefVal <A> val, BiMapper <A, B> bimap ) => new PrefValMapper <A, B>(val, bimap);
public PrefValMapper(PrefVal <A> backing, BiMapper <A, B> bimap) { this.backing = backing; this.bimap = bimap; }
public PrefValOptCachedBlob(PrefVal <Option <A> > backing) { this.backing = backing; }