-
-
Notifications
You must be signed in to change notification settings - Fork 150
Breaking changes (thi.ng rstream)
This page will list historical breaking changes in the thi.ng/rstream package. This is supplementary info in addition to the package readme and changelog...
Type inference for sync()
(aka StreamSync
), one of the main pillars of this
package, was semi-broken in earlier versions and has been updated to better
infer result types from the given object of input streams. For this work, input
sources now MUST be given as object (array form is not allowed anymore, see
below). Furthermore, the two generics have different meanings now and unless you
were using sync<any,any>(...)
these will need to be updated (or, better yet,
removed). See
source
for more details.
// NEW approach
const main = sync({
src: {
a: reactive(23),
b: reactive("foo").map((x) => x.toUpperCase()),
c: reactive([1, 2])
}
});
main
's type can now be inferred as:
StreamSync<
{ a: Stream<number>, b: Subscription<string,string>, c: Stream<number[]> },
{ a: number, b: string, c: number[] }
>
If the xform
(transducer) option is given, the result will be inferred based
on the transducer's result type...
To compensate for the loss of specifying input sources as array (rather than as
an object), the autoObj()
reducer
has been added, allowing for quick conversion of an array into an object with
auto-labeled keys.
const main = sync({
src: autoObj("input", [reactive(23), reactive("foo"), reactive([1, 2])])
});
In this case the type of main
will be inferred as:
StreamSync<
IObjectOf<Stream<number> | Stream<string> | Stream<number[]>>,
IObjectOf<number | string | number[]>
>