@@ -9,7 +9,7 @@ open Fable.PowerPack
99open Thoth.Json
1010
1111let inline toJsonWithTypeInfo value = Encode.Auto.toString( 0 , value)
12- let inline ofJsonWithTypeInfo < 'T > ( json : string ) = Decode.Auto.unsafeFromString < 'T > json
12+
1313
1414[<Literal>]
1515let private modelsKey = " models/"
@@ -22,28 +22,28 @@ let inline private removeItem(key): JS.Promise<unit> =
2222 unbox( Globals.AsyncStorage.removeItem key)
2323
2424/// Removes all rows from the model.
25- let clear < 'a >() =
25+ let inline clear < 'a >() =
2626 let key = modelsKey + typeof< 'a>. FullName
2727 let s : string = [||] |> toJsonWithTypeInfo
2828 setItem( key, s)
2929
3030/// Gets or creates a new model.
31- let private getModel < 'a > ( key ) : JS.Promise < Table < 'a >> =
31+ let inline private getModel < 'a > ( key ) : JS.Promise < Table < 'a >> =
3232 Globals.AsyncStorage.getItem ( key)
3333 |> Promise.map ( function
3434 | null -> [||]
35- | v -> ofJsonWithTypeInfo < Table < 'a >> v)
35+ | v -> Decode.Auto.unsafeFromString v)
3636
3737/// Adds a row to a model
38- let add < 'a > ( data : 'a ) =
38+ let inline add < 'a > ( data : 'a ) =
3939 let key = modelsKey + typeof< 'a>. FullName
4040 getModel< 'a> key
4141 |> Promise.bind ( fun model ->
4242 let newModel : string = Array.append [| unbox data|] model |> toJsonWithTypeInfo
4343 setItem( key, newModel))
4444
4545/// Updates a row in a model
46- let update < 'a >( index , data : 'a ) =
46+ let inline update < 'a >( index , data : 'a ) =
4747 let key = modelsKey + typeof< 'a>. FullName
4848 getModel< 'a> key
4949 |> Promise.bind ( fun model ->
@@ -52,7 +52,7 @@ let update<'a>(index, data:'a) =
5252 setItem( key, newModel))
5353
5454/// Deletes a row from a model
55- let delete < 'a >( index ) =
55+ let inline delete < 'a >( index ) =
5656 let key = modelsKey + typeof< 'a>. FullName
5757 getModel< 'a> key
5858 |> Promise.bind ( fun model ->
@@ -65,7 +65,7 @@ let delete<'a>(index) =
6565 setItem( key, newModel))
6666
6767/// Updates multiple rows in a model
68- let updateMultiple < 'a >( values ) =
68+ let inline updateMultiple < 'a >( values ) =
6969 let key = modelsKey + typeof< 'a>. FullName
7070 getModel< 'a> key
7171 |> Promise.bind ( fun model ->
@@ -75,7 +75,7 @@ let updateMultiple<'a>(values) =
7575 setItem( key, newModel))
7676
7777/// Update data by an update function.
78- let updateWithFunction < 'a >( updateF : 'a [] -> 'a []) =
78+ let inline updateWithFunction < 'a >( updateF : 'a [] -> 'a []) =
7979 let key = modelsKey + typeof< 'a>. FullName
8080 getModel< 'a> key
8181 |> Promise.bind ( fun model ->
@@ -84,7 +84,7 @@ let updateWithFunction<'a>(updateF: 'a[] -> 'a[]) =
8484 setItem( key, newModel))
8585
8686/// Update data by an update function.
87- let updateWithFunctionAndKey < 'a >( updateF : 'a [] -> 'a [], key ) =
87+ let inline updateWithFunctionAndKey < 'a >( updateF : 'a [] -> 'a [], key ) =
8888 let key = modelsKey + typeof< 'a>. FullName + " /" + key
8989 getModel< 'a> key
9090 |> Promise.bind ( fun model ->
@@ -93,48 +93,48 @@ let updateWithFunctionAndKey<'a>(updateF: 'a[] -> 'a[],key) =
9393 setItem( key, newModel))
9494
9595/// Adds multiple rows to a model
96- let addMultiple < 'a >( data : 'a []) =
96+ let inline addMultiple < 'a >( data : 'a []) =
9797 let key = modelsKey + typeof< 'a>. FullName
9898 getModel< 'a> key
9999 |> Promise.bind ( fun model ->
100100 let newModel : string = Array.append data model |> toJsonWithTypeInfo
101101 setItem( key, newModel))
102102
103103/// Replaces all rows of a model
104- let replaceWithKey < 'a >( key , data : 'a []) =
104+ let inline replaceWithKey < 'a >( key , data : 'a []) =
105105 let modelKey = modelsKey + typeof< 'a>. FullName + " /" + key
106106 let newModel : string = data |> toJsonWithTypeInfo
107107 setItem( modelKey, newModel)
108108
109109/// Deletes all rows of a model
110- let deleteWithKey < 'a >( key ) =
110+ let inline deleteWithKey < 'a >( key ) =
111111 let modelKey = modelsKey + typeof< 'a>. FullName + " /" + key
112112 removeItem( modelKey)
113113
114114/// Replaces all rows of a model
115- let replace < 'a >( data : 'a []) =
115+ let inline replace < 'a >( data : 'a []) =
116116 let modelKey = modelsKey + typeof< 'a>. FullName
117117 let newModel : string = data |> toJsonWithTypeInfo
118118 setItem( modelKey, newModel)
119119
120120/// Gets a row from the model
121- let get < 'a >( index : int ) =
121+ let inline get < 'a >( index : int ) =
122122 let key = modelsKey + typeof< 'a>. FullName
123123 getModel< 'a> key
124124 |> Promise.map ( fun model -> model.[ index])
125125
126126/// Gets all rows from the model
127- let getAll < 'a >() =
127+ let inline getAll < 'a >() =
128128 let key = modelsKey + typeof< 'a>. FullName
129129 getModel< 'a> key
130130
131131/// Gets all rows from the model
132- let getAllWithKey < 'a >( key ) =
132+ let inline getAllWithKey < 'a >( key ) =
133133 let key = modelsKey + typeof< 'a>. FullName + " /" + key
134134 getModel< 'a> key
135135
136136/// Gets the row count from the model
137- let count < 'a >() =
137+ let inline count < 'a >() =
138138 let key = modelsKey + typeof< 'a>. FullName
139139 getModel< 'a> key
140140 |> Promise.map ( fun model -> model.Length)
0 commit comments