@zum/flash-client
Advanced tools
Comparing version 0.0.14 to 0.0.15
import { Observable } from 'rxjs'; | ||
import { GetActiveRideDetail, GetActiveRideTraceResponse, GetRideDetail } from './types/ride'; | ||
import { GetActiveRideTraceResponse, GetRideDetail } from './types/ride'; | ||
export declare const subscribeToRidesPrimary: <T>(rideIds: string[], getRideImpl: GetRideDetail<T>) => Observable<{ | ||
@@ -13,12 +13,2 @@ rideId: string; | ||
export declare const unsubscribeToRidesSecondary: () => Promise<void>; | ||
export declare const subscribeToActiveRidesPrimary: <T>(rideIds: string[], getActiveRideImpl: GetActiveRideDetail<T>) => Observable<{ | ||
rideId: string; | ||
result: T; | ||
}>; | ||
export declare const unsubscribeToActiveRidesPrimary: () => Promise<void>; | ||
export declare const subscribeToActiveRidesSecondary: <T>(rideIds: string[], getActiveRideImpl: GetActiveRideDetail<T>) => Observable<{ | ||
rideId: string; | ||
result: T; | ||
}>; | ||
export declare const unsubscribeToActiveRidesSecondary: () => Promise<void>; | ||
export declare const subscribeToRideRouteTrace: <T>(rideId: string, getRideTraceLastFetchIndex: () => Observable<number>, getActiveRideTrace: GetActiveRideTraceResponse<T>) => Observable<{ | ||
@@ -25,0 +15,0 @@ rideId: string; |
@@ -20,23 +20,2 @@ "use strict"; | ||
exports.unsubscribeToRidesSecondary = () => unsubscribe(topicTypes_1.FlashTopic.RIDE_LIST_SECONDARY); | ||
exports.subscribeToActiveRidesPrimary = (rideIds, getActiveRideImpl) => { | ||
return subscribeToActiveRides(topicTypes_1.FlashTopic.ACTIVE_RIDE_LIST_PRIMARY, rideIds, getActiveRideImpl); | ||
}; | ||
exports.unsubscribeToActiveRidesPrimary = () => unsubscribe(topicTypes_1.FlashTopic.ACTIVE_RIDE_LIST_PRIMARY); | ||
exports.subscribeToActiveRidesSecondary = (rideIds, getActiveRideImpl) => { | ||
return subscribeToActiveRides(topicTypes_1.FlashTopic.ACTIVE_RIDE_LIST_SECONDARY, rideIds, getActiveRideImpl); | ||
}; | ||
exports.unsubscribeToActiveRidesSecondary = () => unsubscribe(topicTypes_1.FlashTopic.ACTIVE_RIDE_LIST_SECONDARY); | ||
const subscribeToActiveRides = (topic, rideIds, getActiveRideDetails) => { | ||
const activeRideObservableArray = []; | ||
const activeRidesObservable = initializer_1.getSubscriptionManager().subscribe(topic, rideIds); | ||
for (const rideId of rideIds) { | ||
const activeRideObservable = activeRidesObservable.pipe(operators_1.filter((event) => event.entityId === rideId), operators_1.throttleTime(DEFAULT_THROTTLE_MS, rxjs_1.asyncScheduler, throttleConfig), operators_1.switchMap((event) => { | ||
return getActiveRideDetails(event.entityId).pipe(operators_1.map((activeRide) => { | ||
return { rideId: event.entityId, result: activeRide }; | ||
})); | ||
}), operators_1.tap((val) => console.log(`Active Ride Flash Event ${JSON.stringify(val)}`))); | ||
activeRideObservableArray.push(activeRideObservable); | ||
} | ||
return rxjs_1.merge(...activeRideObservableArray); | ||
}; | ||
const subscribeToRides = (topic, rideIds, getRideDetail) => { | ||
@@ -43,0 +22,0 @@ const rideObservableArray = []; |
import { Observable } from 'rxjs'; | ||
export declare type GetActiveRideDetail<T> = (rideId: string) => Observable<T>; | ||
export declare type ActiveRideResponseObservable<T> = Observable<{ | ||
rideId: string; | ||
result: T; | ||
}>; | ||
export declare type GetRideDetail<T> = (rideId: string) => Observable<T>; | ||
@@ -8,0 +3,0 @@ export declare type RideResponseObservable<T> = Observable<{ |
export declare enum FlashTopic { | ||
RIDE_LIST_PRIMARY = "RIDE_LIST_PRIMARY", | ||
RIDE_LIST_SECONDARY = "RIDE_LIST_SECONDARY", | ||
ROUTE_TRACE = "ROUTE_TRACE", | ||
ACTIVE_RIDE_LIST_PRIMARY = "ACTIVE_RIDE_LIST_PRIMARY", | ||
ACTIVE_RIDE_LIST_SECONDARY = "ACTIVE_RIDE_LIST_SECONDARY" | ||
ROUTE_TRACE = "ROUTE_TRACE" | ||
} | ||
//# sourceMappingURL=topicTypes.d.ts.map |
@@ -8,5 +8,3 @@ "use strict"; | ||
FlashTopic["ROUTE_TRACE"] = "ROUTE_TRACE"; | ||
FlashTopic["ACTIVE_RIDE_LIST_PRIMARY"] = "ACTIVE_RIDE_LIST_PRIMARY"; | ||
FlashTopic["ACTIVE_RIDE_LIST_SECONDARY"] = "ACTIVE_RIDE_LIST_SECONDARY"; | ||
})(FlashTopic = exports.FlashTopic || (exports.FlashTopic = {})); | ||
//# sourceMappingURL=topicTypes.js.map |
@@ -6,9 +6,3 @@ import { asyncScheduler, merge, Observable } from 'rxjs'; | ||
import { FlashTopic } from '../topic/topicTypes'; | ||
import { | ||
ActiveRideResponseObservable, | ||
GetActiveRideDetail, | ||
GetActiveRideTraceResponse, | ||
GetRideDetail, | ||
RideResponseObservable, | ||
} from './types/ride'; | ||
import { GetActiveRideTraceResponse, GetRideDetail, RideResponseObservable } from './types/ride'; | ||
@@ -38,47 +32,2 @@ const throttleConfig = { | ||
export const subscribeToActiveRidesPrimary = <T>( | ||
rideIds: string[], | ||
getActiveRideImpl: GetActiveRideDetail<T>, | ||
): Observable<{ rideId: string; result: T }> => { | ||
return subscribeToActiveRides(FlashTopic.ACTIVE_RIDE_LIST_PRIMARY, rideIds, getActiveRideImpl); | ||
}; | ||
export const unsubscribeToActiveRidesPrimary = (): Promise<void> => unsubscribe(FlashTopic.ACTIVE_RIDE_LIST_PRIMARY); | ||
export const subscribeToActiveRidesSecondary = <T>( | ||
rideIds: string[], | ||
getActiveRideImpl: GetActiveRideDetail<T>, | ||
): Observable<{ rideId: string; result: T }> => { | ||
return subscribeToActiveRides(FlashTopic.ACTIVE_RIDE_LIST_SECONDARY, rideIds, getActiveRideImpl); | ||
}; | ||
export const unsubscribeToActiveRidesSecondary = (): Promise<void> => | ||
unsubscribe(FlashTopic.ACTIVE_RIDE_LIST_SECONDARY); | ||
const subscribeToActiveRides = <T>( | ||
topic: string, | ||
rideIds: string[], | ||
getActiveRideDetails: GetActiveRideDetail<T>, | ||
): ActiveRideResponseObservable<T> => { | ||
const activeRideObservableArray: ActiveRideResponseObservable<T>[] = []; | ||
const activeRidesObservable = getSubscriptionManager().subscribe(topic, rideIds); | ||
for (const rideId of rideIds) { | ||
const activeRideObservable = activeRidesObservable.pipe( | ||
filter((event) => event.entityId === rideId), | ||
throttleTime(DEFAULT_THROTTLE_MS, asyncScheduler, throttleConfig), | ||
switchMap((event: FlashEvent) => { | ||
return getActiveRideDetails(event.entityId).pipe( | ||
map((activeRide: T) => { | ||
return { rideId: event.entityId, result: activeRide }; | ||
}), | ||
); | ||
}), | ||
tap((val) => console.log(`Active Ride Flash Event ${JSON.stringify(val)}`)), | ||
); | ||
activeRideObservableArray.push(activeRideObservable); | ||
} | ||
return merge(...activeRideObservableArray); | ||
}; | ||
const subscribeToRides = <T>( | ||
@@ -85,0 +34,0 @@ topic: string, |
import { Observable } from 'rxjs'; | ||
export type GetActiveRideDetail<T> = (rideId: string) => Observable<T>; | ||
export type ActiveRideResponseObservable<T> = Observable<{ rideId: string; result: T }>; | ||
export type GetRideDetail<T> = (rideId: string) => Observable<T>; | ||
@@ -7,0 +4,0 @@ export type RideResponseObservable<T> = Observable<{ rideId: string; result: T }>; |
@@ -5,4 +5,2 @@ export enum FlashTopic { | ||
ROUTE_TRACE = 'ROUTE_TRACE', | ||
ACTIVE_RIDE_LIST_PRIMARY = 'ACTIVE_RIDE_LIST_PRIMARY', | ||
ACTIVE_RIDE_LIST_SECONDARY = 'ACTIVE_RIDE_LIST_SECONDARY', | ||
} |
{ | ||
"name": "@zum/flash-client", | ||
"version": "0.0.14", | ||
"version": "0.0.15", | ||
"description": "Client for connecting to Zum Flash server", | ||
@@ -5,0 +5,0 @@ "license": "UNLICENSED", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
576208
827