You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Typescript is too inflexible to let me write a type for both the wrapped and unwrapped version of an observ-struct without writing two separate type definitions.
The text was updated successfully, but these errors were encountered:
Honestly; if I wanted to a do a well typed version of observ or observ-struct I would start changing the interface.
aka instead of:
var state = ObservStruct({
fruits: ObservStruct({
apples: Observ(3),
oranges: Observ(5)
}),
customers: Observ(5)
})
// plain object
var state = {
fruits: {
apples: 3,
oranges: 5
},
customers: 5
}
// ObservCursor : <T>(T) => Cursor<T>
var cursor = ObservCursor(state);
// get : <T>(this: Cursor<T>) => T
cursor.get();
// update : <T>(this: Cursor<T>, path: String, value: any) => void
cursor.update('fruits.apples', 4);
var state = {
fruits: null,
customers: 5
}
var rootCursor = ObservCursor(state);
var fruitsState = {
apples: 3,
oranges: 5
}
var fruitCursor = ObservCursor(fruitsState);
// merge : <T, S>(this: Cursor<T>, keyPath: String, Cursor<S>) => void
cursor.merge('fruits', fruitCursor);
I have no idea of this ObservCursor would work. I would hope that merge() allows us to get some of the cool features we wanted from arbitrarly nested observ...
Typescript is too inflexible to let me write a type for both the wrapped and unwrapped version of an observ-struct without writing two separate type definitions.
The text was updated successfully, but these errors were encountered: