This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { MapDeltaStream } from '../delta-streams/streams/map' | |
| import { Point } from './Points' | |
| import { mapValues } from 'lodash' | |
| import { deltaNone, deltaUnknown } from '../delta-streams/deltas/collection' | |
| import mapDeltaStream from '../delta-streams/mapDeltaStream' | |
| export default (points: MapDeltaStream<Point>): MapDeltaStream<number> => { | |
| const outSubject = mapDeltaStream<number>({}) | |
| points.stream.subscribe(({ data, delta }) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { get } from 'lodash' | |
| export interface EqualByProperties<TObject extends object> { | |
| (): (object1: TObject, object2: TObject) => boolean | |
| <TKey extends keyof TObject>(key: TKey): EqualByProperties<TObject> | |
| <TKey1 extends keyof TObject, TKey2 extends keyof TObject[TKey1]>( | |
| ...key: readonly [TKey1, TKey2] | |
| ): EqualByProperties<TObject> | |
| <TKey1 extends keyof TObject, TKey2 extends keyof TObject[TKey1], TKey3 extends keyof TObject[TKey1][TKey2]>( | |
| ...key: readonly [TKey1, TKey2, TKey3] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Observable, Subject } from 'rxjs' | |
| import { distinctUntilChanged, map, withLatestFrom } from 'rxjs/operators' | |
| import { apply, assocPath, path } from 'ramda' | |
| type StreamLens<TObject, TOriginal> = <TKey extends keyof TObject | undefined = undefined>( | |
| key?: TKey, | |
| ) => TKey extends keyof TObject | |
| ? StreamLens<TObject[TKey], TOriginal> | |
| : { | |
| readonly stream: Observable<TObject> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function useObserved<TObject>(observable: Observable<TObject>) { | |
| const [state, setState] = useState<TObject>() | |
| useEffect(() => { | |
| const subscription = observable.subscribe(setState) | |
| return () => subscription.unsubscribe() | |
| }, []) | |
| return state | |
| } |