An object representing a map of [[Observable]] or [[StateObserveable]]
A type representing an objectc, a map of values, based on a map of [[Observable]] or StateObservable and the values those observable stream.
For example
type State = MapOfStateFromMapOfObservables<{
users: Observable<User[]>>,
active: StateObservable<boolean>
}
// equates to
type State = { readonly users: number, active: boolean }
In this example you are building a state object where
state.users
is immutauble and not controlled by the application
while state.active
is a StateObservable to which you can
not only subscribe to get the "next" value of .active
but also
emit to, aka set it's state
Returns a type that makes all values of object T readonly if they belong to keys in type K
For example:
type User = { id: number, name: string, age: number }
type UserWithProtectedId = Readonly<User, 'id'>
const user: Readonly<User, 'id'> = { id: 24, name: 'Bob', age: 54 }
user.age = 55 // no problem here
user.id = 77 // should not compile
Returns a type that makes all values of object T readonly if they are of type V
For example:
type User = { id: number, name: string, age: number }
const user: Readonly<User, number> = { id: 24, name: 'Bob', age: 54 }
user.age = 55 // should not compile
user.id = 77 // should not compile
user.name = "Alice" // no problem here
State$ describes an Observable
that is the composition of
of a map of observables.
See MapOfStateFromMapOfObservables for more information on the data streamed by this observable.
createState :: MapOfObservables t => MapOfObservables t -> State$ t
Creates a single state observable from a map of ObservableLike
The keys of mapOfObservables
are reduced into an array of thruples
where each thruple contains:
0 - The key / property being iterated
1 - A getter function for that property
2 _ A setter function for that property
Since values on the mapOfObservables
object are either Obervable
or
StateObservable, the thruple created for both differs slightly in
that the setter function for Observables
logs a warning to the
console in development mode since data/state for Obserable
s is considered
immutable.
Finally the list of (key, getter, setter) data is reduced into a single object.
Object.defineProperty
is used to decalre get
and set
on the accumulated
object.
See MapOfStateFromMapOfObservables for more information on the data streamed by this observable.
TODO I think this can be simplified with less iterations
Map (object) of observables.
An observable whos data stream matches the shape of mapOfObservables
Generated using TypeDoc
Returns a type describing all keys of object T that are of type V
For example:
type User = { id: number, name: string, age: number } type NumericUserProperties = KeyOfType<User, number> // 'id' | 'age'