本文整理汇总了TypeScript中rxjs/operator/filter.filter类的典型用法代码示例。如果您正苦于以下问题:TypeScript filter类的具体用法?TypeScript filter怎么用?TypeScript filter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了filter类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: makeHistory
handler: (action$: O<A<any>>, options: any) => {
const { re }: { re: (action: A<any>) => void; } = options;
const history = makeHistory(historyImpl, (path => {
const data = router(path);
re({ type: routeType, data });
}));
let isStarted = false;
return share.call(
filter.call(
_do.call(
filter.call(
_do.call(
action$,
() => {
if (!isStarted) {
isStarted = true;
history.start();
}
}
),
(action: A<any>): boolean => action.type === goToType
),
({ data: path }: { data: string }) => history.go(path)
),
() => false // remove all
)
);
}
开发者ID:bouzuya,项目名称:boa-handler-history,代码行数:28,代码来源:index.ts
示例2: listenForRouterMethodActions
export function listenForRouterMethodActions(router: Router, location: Location, actions$: Observable<Action>) {
filter.call(actions$, action => routerActionTypes.indexOf(action.type) > -1)
.subscribe(action => {
const { path, query: queryParams, extras = {} }: RouterMethodCall = action.payload;
let commands: any[] = Array.isArray(path) ? path : [path];
switch (action.type) {
case routerActions.GO:
router.navigate(commands, Object.assign({}, extras, { queryParams }));
break;
case routerActions.REPLACE:
router.navigate(commands, Object.assign({}, extras, { queryParams, replaceUrl: true }));
break;
case routerActions.SEARCH:
let urlTree: UrlTree = router.parseUrl(router.url);
urlTree.queryParams = queryParams;
router.navigateByUrl(urlTree, extras);
break;
case routerActions.SHOW:
router.navigate(commands, Object.assign({}, extras, { queryParams, skipLocationChange: true }));
break;
case routerActions.BACK:
location.back();
break;
case routerActions.FORWARD:
location.forward();
break;
}
});
}
开发者ID:ngrx,项目名称:router-store,代码行数:35,代码来源:connect.ts
示例3: listenForStoreChanges
export function listenForStoreChanges(router: Router, store: Store<any>) {
const storeAndRouter$ = withLatestFrom.call(selectRouter(store), getLatestUrl(router));
const mismatch$ = filter.call(storeAndRouter$, ([ rs, url ]) => rs.path !== url);
const newPath$ = map.call(mismatch$, ([ rs ]) => rs.path);
newPath$.subscribe(url => router.navigateByUrl(url));
}
开发者ID:ngrx,项目名称:router-store,代码行数:7,代码来源:connect.ts
示例4: Error
return moduleRefPromise.then((moduleRef) => {
const transitionId = moduleRef.injector.get(ÉľTRANSITION_ID, null);
if (!transitionId) {
throw new Error(
`renderModule[Factory]() requires the use of BrowserModule.withServerTransition() to ensure
the server-rendered app can be properly bootstrapped into a client app.`);
}
const applicationRef: ApplicationRef = moduleRef.injector.get(ApplicationRef);
return toPromise
.call(first.call(filter.call(applicationRef.isStable, (isStable: boolean) => isStable)))
.then(() => {
const platformState = platform.injector.get(PlatformState);
// Run any BEFORE_APP_SERIALIZED callbacks just before rendering to string.
const callbacks = moduleRef.injector.get(BEFORE_APP_SERIALIZED, null);
if (callbacks) {
for (const callback of callbacks) {
try {
callback();
} catch (e) {
// Ignore exceptions.
console.warn('Ignoring BEFORE_APP_SERIALIZED Exception: ', e);
}
}
}
const output = platformState.renderToString();
platform.destroy();
return output;
});
});
开发者ID:AnthonyPAlicea,项目名称:angular,代码行数:31,代码来源:utils.ts
示例5: run
export default function run(app: Handler): void {
const subject = new Subject<A<any>>();
const $ = subject.asObservable();
const filtered$ = filter.call($, action => !!action);
const action$ = share.call(filtered$);
const re = (action: A<any>) => setTimeout(() => subject.next(action));
app(action$, { re }).subscribe(re);
};
开发者ID:bouzuya,项目名称:boa-core,代码行数:8,代码来源:run.ts
示例6: makeRender
const handler = (action$: O<A<any>>, options: any): O<A<any>> => {
const { re } = options;
let start = false;
let renderToHTML = makeRender();
return share.call(
filter.call(
_do.call(
filter.call(
_do.call(
action$,
() => {
if (!start) {
start = true;
const proc = (request: any, response: any) => {
const { route, params } = http(request.path);
re({
type: httpRequestType,
data: { route, params, http: { request, response } }
});
};
setTimeout(() => runServer(dir, middlewares, port, proc), 0);
}
}
),
(action: A<any>): boolean => action.type === httpResponseType
),
({ data: { error, state, http: { response } } }) => {
if (error && error.message === 'redirect') {
const { status, path } = error;
response.redirect(status, path);
} else if (error) {
const { status, path } = error;
response.send(error.message);
} else {
const vtree = render(state, { create, e: (): void => null });
const rendered = renderToHTML(vtree);
const { result: html } = rendered;
renderToHTML = rendered.render;
response.send(html);
}
}
),
() => false
)
);
};
开发者ID:bouzuya,项目名称:boa-handler-init,代码行数:46,代码来源:index.ts
示例7: trackPageViews
/**
* Intended to be called only once. Subscribes to router events and sends a page view
* after each ended navigation event.
*/
trackPageViews() {
if (this._enabled) {
filter.call(this._router.events, (event) => event instanceof NavigationEnd)
.subscribe(() => {
ga('send', {hitType: 'pageview', page: this._location.path()});
});
}
}
开发者ID:Chenlevin,项目名称:ng-bootstrap,代码行数:12,代码来源:analytics.ts
示例8: connectRouterActions
export function connectRouterActions(router: Router, store: Store<any>) {
const routerAndStore$ = withLatestFrom.call(getLatestUrl(router), selectRouter(store));
const mismatchUrl$ = filter.call(routerAndStore$, ([ url, rs ]) => (rs && rs.path !== url || !rs));
const updateLocation$ = map.call(mismatchUrl$, ([ path ]) => {
return { type: routerActions.UPDATE_LOCATION, payload: { path }};
});
updateLocation$.subscribe(store);
}
开发者ID:ngrx,项目名称:router-store,代码行数:9,代码来源:connect.ts
示例9:
return moduleRefPromise.then((moduleRef) => {
const applicationRef: ApplicationRef = moduleRef.injector.get(ApplicationRef);
return toPromise
.call(first.call(filter.call(applicationRef.isStable, (isStable: boolean) => isStable)))
.then(() => {
const output = platform.injector.get(PlatformState).renderToString();
platform.destroy();
return output;
});
});
开发者ID:manekinekko,项目名称:angular,代码行数:10,代码来源:utils.ts
示例10:
const initializer = () => {
const app = injector.get<ApplicationRef>(ApplicationRef);
if (!('serviceWorker' in navigator)) {
return;
}
const onStable =
op_filter.call(app.isStable, (stable: boolean) => !!stable) as Observable<boolean>;
const isStable = op_take.call(onStable, 1) as Observable<boolean>;
const whenStable = op_toPromise.call(isStable) as Promise<boolean>;
return whenStable.then(() => navigator.serviceWorker.register(script, options))
.then(() => undefined) as Promise<void>;
};
开发者ID:cartant,项目名称:angular,代码行数:12,代码来源:module.ts
注:本文中的rxjs/operator/filter.filter类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论