本文整理汇总了TypeScript中rxjs/ajax.ajax.getJSON方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ajax.getJSON方法的具体用法?TypeScript ajax.getJSON怎么用?TypeScript ajax.getJSON使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rxjs/ajax.ajax
的用法示例。
在下文中一共展示了ajax.getJSON方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getDepth
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)),
)
}
示例2: merge
(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>())
)
示例3:
.pipe(switchMap<View | null, IView[]>(() => ajax.getJSON<IView[]>("api/views")))
示例4:
.pipe(mergeMap(() => ajax.getJSON<IViewData>(`api/viewdata/${selectedView.id}`).pipe(catchError(() => EMPTY))))
示例5: observableDefer
export const allViews: Observable<IView[] | null> = observableDefer(() => ajax.getJSON<IView[]>("api/views"));
示例6:
export const getMappings = (server: IServer) =>
ajax.getJSON(buildApiUrl(server, '/mappings'))
示例7: switchMap
switchMap(project => ajax.getJSON<IDetailedProject>(`api/projects/${project.id}`).pipe(
map(detailedProject => project.withBuildConfigurations(detailedProject.buildConfigurations.map(BuildConfiguration.fromContract))),
startWith<Project | null>(null))),
示例8: observableDefer
const initialRootProjects: Observable<Project> = observableDefer(() => ajax.getJSON<IBasicProject[]>("api/projects")).pipe(