本文整理汇总了TypeScript中angular2/core.EventEmitter.subscribe方法的典型用法代码示例。如果您正苦于以下问题:TypeScript EventEmitter.subscribe方法的具体用法?TypeScript EventEmitter.subscribe怎么用?TypeScript EventEmitter.subscribe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angular2/core.EventEmitter
的用法示例。
在下文中一共展示了EventEmitter.subscribe方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
.then((fixture: ComponentFixture) => {
fixture.detectChanges();
ee.subscribe(null, null, () => {
let logo: Element = fixture.nativeElement.querySelector('glyph');
expect(logo.querySelector('svg')).not.toBe(null);
});
});
示例2: constructor
constructor(public location: Location, public route: Router) {
this.locationChanged = false;
this.actionEmitter = ActionNavigation.getEmitter();
this.actionEmitter.subscribe(event => {
//this.location.go('/'+event);
//console.log('emitting', ActionNavigation.getEventEmitter(event));
ActionNavigation.getEventEmitter(event).emit('start');
//this.route.recognize(event);
});
}
示例3: constructor
constructor() {
this.loginEvent = new EventEmitter();
// If I implement revocation of JWTs from the server side, make sure to
// cache JWTs that are revoked until they expire.
this.loginEvent.subscribe((jwtResult: IJWT) => {
this.jwtResult = jwtResult;
});
this.loggedIn = this.loginEvent
.map((jwtResult: IJWT) => {
return Boolean(jwtResult && jwtResult.aud);
});
// Necessary because you can't negate an Observable<boolean> or assign
// within a map function inside a template
this.loggedOut = this.loggedIn.map(b => !b);
}
示例4: constructor
constructor() {
this.webSocket = new WebSocket("ws://localhost:3001");
this.isReady = false;
this.pending = new Array<string>();
this.emitter = new EventEmitter<string>();
this.resolveMap = new Map<Object, Object>();
this.webSocket.onerror = ((event) => {
console.log(event);
});
this.webSocket.onmessage = ((event) => {
this.emitter.next(event);
});
this.webSocket.onclose = ((event) => {
console.log(event);
});
this.webSocket.onopen = ((event) => {
console.log(event);
this.isReady = true;
this.pending.forEach(request => {
this.webSocket.send(request);
});
});
this.emitter.subscribe((event) => {
let data = JSON.parse(event.data);
let resolve = this.resolveMap.get(data.file);
console.log(data.content);
console.log(resolve);
});
}
示例5: reloadEvent
@Input() set reloadEvent(v: EventEmitter<void>) {
v.subscribe(() => this.refresh());
}
示例6: Promise
return new Promise((resolve, reject) => {
this.loginEvent.subscribe(
(jwtResult: IJWT) => { resolve(jwtResult); },
(err: any) => { reject(err); }
);
});