Skip to content

Instantly share code, notes, and snippets.

View shairez's full-sized avatar

Shai Reznik shairez

View GitHub Profile
@shairez
shairez / fake-http.ts
Created May 19, 2018 07:23
Code examples for the switched-a-map blog post
// A FAKE SERVER OBJECT:
const http = {
getAwesomeMessagesObservable(name): Observable<string> {
return of(`${name} is awesome! (msg #1)`,
`${name} is awesome! (msg #2)`);
}
// the "of" returns an observable
// this particular one will produce 2 events
}
@shairez
shairez / tasks.service.ts
Created August 31, 2017 15:32
Service Example for a testing question
switchNodeParents(taskNode: TaskNode, newParentTaskNode: TaskNode, toIndex: PutAfterThisNode | number | 'last' = 'last') {
this.removeNodeFromCurrentParent(taskNode);
this.addTaskNode(taskNode, newParentTaskNode, toIndex);
}
createAndAddTaskNode(task: Task, toParentNode: TaskNode = null, toIndex: PutAfterThisNode | 'last' | number = 0): TaskNode {
this.tasksByIds.set(task.id, task);
let taskNode = new TaskNode({ task });
this.addTaskNode(taskNode, toParentNode, toIndex);
return taskNode;
{
"taskName": "test",
"args": [],
"isTestCommand": true,
"problemMatcher": {
"fileLocation": ["absolute"],
"pattern": [
{
"regexp": "(Expected.+\\.)$",
"message": 1