Esempio n. 1
0
        // 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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 public static ICachedBlob <A> optToCachedBlob <A>(
     this PrefVal <Option <A> > val
     ) => new PrefValOptCachedBlob <A>(val);
Esempio n. 4
0
 public static PrefVal <B> bimap <A, B>(
     this PrefVal <A> val, BiMapper <A, B> bimap
     ) => new PrefValMapper <A, B>(val, bimap);
Esempio n. 5
0
 public PrefValMapper(PrefVal <A> backing, BiMapper <A, B> bimap)
 {
     this.backing = backing;
     this.bimap   = bimap;
 }
Esempio n. 6
0
 public PrefValOptCachedBlob(PrefVal <Option <A> > backing)
 {
     this.backing = backing;
 }