This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Injectable() | |
export class TimeService implements OnDestroy { | |
// ... some useful stuff | |
ngOnDestroy(): void { | |
// ... some clean up logic | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Injectable() | |
export class TimeService { | |
// ... some useful stuff | |
onDestroy(): void { | |
// ... some clean up logic | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Injectable() | |
export class TimeService implements OnDestroy { | |
// ... some useful stuff | |
ngOnDestroy(): void { | |
// ... some clean up logic | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
h1: { | |
color: pink; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var injector = {}; //created at app-bootstrap time | |
injector["UserProvider"] = new EagerUserService(); // at EagerModule evaluation time | |
injector["UserProvider"] = new UserService(); // at AppModule evaluation time | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var lazyInjector = {}; // provided at lazy-module start | |
lazyInjector.prototype = injector; // 'inherit' the root injector | |
// and then at LazyModule instantiation: | |
lazyInjector["UserProfile"] = new LazyUserService(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class AuthService { | |
getUser(): Promise<User> { | |
// probably make a xhr but we'll just | |
return Promise.resolve(User.Empty); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it('should redirect to login if getUser returns the empty user', () => { | |
// given | |
// setup the empty user | |
auth.getUser.and.returnValue(Promise.resolve(User.Empty)); | |
// when | |
comp.login(); | |
flushMictrotasks(); // forse the promise microtask on the call stack and let it run | |
// then | |
expect(router.navigate).toHaveBeenCalledWith('/login'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const source = from([1, 2, 3]); | |
source.subscribe(x => console.log('observable', x), null, () => console.info("completed")); | |
// observable 1 | |
// observable 2 | |
// observable 3 | |
// completed | |
source.toPromise().then(x => console.log('toPromise', x)); | |
// toPromise 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"configurations": [ | |
{ | |
"type": "node", | |
"request": "launch", | |
"name": "Debug Jest for current test file", | |
"program": "${workspaceFolder}\\node_modules\\jest\\bin\\jest", | |
"//comment": "--runInBand allows the 'debugger' and breakpoints to be hit", | |
"//comment1": "--verbosity false due to bug where console.log is not seen on the console", | |
"//comment2": "${fileBaseName} will give the filename that is being edited in VS Code", |
OlderNewer