Example #1
1
export const createMapping = (server: IServer, mapping: Partial<IMapping>) =>
    ajax.post(
        buildApiUrl(server, '/mappings'),
        mapping,
        { 'Content-Type': 'application/json' }
    )
Example #2
0
export function getDepth(direction: Direction) {
  const directionalCompare = (a: OrderType, b: OrderType) =>
    direction === Direction.buy
      ? b.price > a.price
      : a.price > b.price
  return ajax.getJSON<OrderType[]>(`${URL}/depth/${direction}`).pipe(
    map((orders) => orders.sort((a, b) => directionalCompare(a, b) ? 1 : -1).slice(0, 3)),
  )
}
    (selectedView: IView | null) => selectedView == null
      ? EMPTY
      : merge(
        // initial fetch
        ajax.getJSON<IViewData>(`api/viewdata/${selectedView.id}`).pipe(catchError(() => EMPTY)),

        // keep polling
        observableOf(null)
          .pipe(delay(3000))
          .pipe(mergeMap(() => ajax.getJSON<IViewData>(`api/viewdata/${selectedView.id}`).pipe(catchError(() => EMPTY))))
          .pipe(repeat<IViewData | null>())
      )
 .pipe(switchMap<View | null, IView[]>(() => ajax.getJSON<IView[]>("api/views")))
 .pipe(mergeMap(() => ajax.getJSON<IViewData>(`api/viewdata/${selectedView.id}`).pipe(catchError(() => EMPTY))))
export const allViews: Observable<IView[] | null> = observableDefer(() => ajax.getJSON<IView[]>("api/views"));
Example #7
0
export const getMappings = (server: IServer) =>
    ajax.getJSON(buildApiUrl(server, '/mappings'))
Example #8
0
export const deleteMapping = (server: IServer, mappingId: string) =>
    ajax.delete(buildApiUrl(server, `/mappings/${mappingId}`))
Example #9
0
export const updateMapping = (server: IServer, mapping: IMapping) =>
    ajax.put(
        buildApiUrl(server, `/mappings/${mapping.id}`),
        mapping,
        { 'Content-Type': 'application/json' }
    )
Example #10
0
export const getMapping = (server: IServer, mappingId: string) =>
    ajax.getJSON(buildApiUrl(server, `/mappings/${mappingId}`))