* Turns an object, array or function into a reactive structure. * @param v the value which should become observable.
(v: any, arg2?: any, arg3?: any)
| 103 | * @param v the value which should become observable. |
| 104 | */ |
| 105 | function createObservable(v: any, arg2?: any, arg3?: any) { |
| 106 | // @observable someProp; (2022.3 Decorators) |
| 107 | if (is20223Decorator(arg2)) { |
| 108 | return observableAnnotation.decorate_20223_(v, arg2) |
| 109 | } |
| 110 | |
| 111 | // @observable someProp; |
| 112 | if (isStringish(arg2)) { |
| 113 | storeAnnotation(v, arg2, observableAnnotation) |
| 114 | return |
| 115 | } |
| 116 | |
| 117 | // already observable - ignore |
| 118 | if (isObservable(v)) { |
| 119 | return v |
| 120 | } |
| 121 | |
| 122 | // plain object |
| 123 | if (isPlainObject(v)) { |
| 124 | return observable.object(v, arg2, arg3) |
| 125 | } |
| 126 | |
| 127 | // Array |
| 128 | if (Array.isArray(v)) { |
| 129 | return observable.array(v, arg2) |
| 130 | } |
| 131 | |
| 132 | // Map |
| 133 | if (isES6Map(v)) { |
| 134 | return observable.map(v, arg2) |
| 135 | } |
| 136 | |
| 137 | // Set |
| 138 | if (isES6Set(v)) { |
| 139 | return observable.set(v, arg2) |
| 140 | } |
| 141 | |
| 142 | // other object - ignore |
| 143 | if (typeof v === "object" && v !== null) { |
| 144 | return v |
| 145 | } |
| 146 | |
| 147 | // anything else |
| 148 | return observable.box(v, arg2) |
| 149 | } |
| 150 | assign(createObservable, observableDecoratorAnnotation) |
| 151 | |
| 152 | export interface IObservableValueFactory { |
nothing calls this directly
no test coverage detected
searching dependent graphs…