Skip to content
This repository was archived by the owner on Oct 1, 2018. It is now read-only.

Commit fa53e7d

Browse files
committed
stackblitz implementation
1 parent 57a8909 commit fa53e7d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+104
-324
lines changed

src/operator-docs/combination/combineAll.ts

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
import { OperatorDoc } from '../operator.model';
22

3+
const EXAMPLE_CODE = `
4+
import { map, combineAll, take } from 'rxjs/operators';
5+
import { interval } from 'rxjs/observable/interval';
6+
import { fromEvent } from 'rxjs/observable/fromEvent';
7+
8+
const clicks = fromEvent(document, 'click');
9+
const higherOrder = clicks.pipe(
10+
map(ev =>
11+
interval(Math.random()*2000).pipe(take(3))
12+
),
13+
take(2)
14+
);
15+
16+
const result = higherOrder.pipe(
17+
combineAll()
18+
);
19+
20+
result.subscribe(x => {
21+
const output = \`<h3>$\{x.toString\(\)\}<h3>\`;
22+
document.getElementById('output').innerHTML += output;
23+
});
24+
`;
25+
326
export const combineAll: OperatorDoc = {
427
name: 'combineAll',
528
operatorType: 'combination',
@@ -50,30 +73,7 @@ export const combineAll: OperatorDoc = {
5073
{
5174
name:
5275
'Map two click events to a finite interval Observable, then apply <span class="markdown-code">combineAll</span>',
53-
code: `import { map, combineAll, take } from 'rxjs/operators';
54-
import { interval } from 'rxjs/observable/interval';
55-
import { fromEvent } from 'rxjs/observable/fromEvent';
56-
57-
const clicks = fromEvent(document, 'click');
58-
const higherOrder = clicks.pipe(
59-
map(ev =>
60-
interval(Math.random()*2000).pipe(take(3))
61-
),
62-
take(2)
63-
);
64-
65-
const result = higherOrder.pipe(
66-
combineAll()
67-
);
68-
69-
result.subscribe(x => {
70-
const output = \`<h3>$\{x.toString\(\)\}<h3>\`;
71-
document.getElementById('output').innerHTML = output;
72-
});`,
73-
externalLink: {
74-
platform: 'JSBin',
75-
url: 'http://jsbin.com/peparawuvo/1/embed?js,console,output'
76-
}
76+
code: EXAMPLE_CODE
7777
}
7878
],
7979
relatedOperators: ['combineLatest', 'mergeAll'],

src/operator-docs/combination/combineLatest.ts

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
import { OperatorDoc } from '../operator.model';
22

3+
const EXAMPLE_CODE = `
4+
import { combineLatest } from 'rxjs/operators/combineLatest';
5+
import { of } from 'rxjs/observable/of';
6+
7+
const weight = of(70, 72, 76, 79, 75);
8+
const height = of(1.76, 1.77, 1.78);
9+
const bmi = weight.pipe(
10+
combineLatest(height, (w, h) => w / (h * h))
11+
);
12+
/*
13+
Output:
14+
BMI is 24.212293388429753
15+
BMI is 23.93948099205209
16+
BMI is 23.671253629592222
17+
*/
18+
bmi.subscribe(x => {
19+
const output = \`<h3>BMI is $\{x.toString\(\)\}<h3>\`;
20+
document.getElementById('output').innerHTML += output;
21+
});
22+
`;
23+
324
export const combineLatest: OperatorDoc = {
425
name: 'combineLatest',
526
operatorType: 'combination',
@@ -55,27 +76,7 @@ export const combineLatest: OperatorDoc = {
5576
{
5677
name:
5778
'Dynamically calculate the Body-Mass Index from an Observable of weight and one for height',
58-
code: `
59-
import { combineLatest } from 'rxjs/operators;
60-
import { of } from 'rxjs/observable/of';
61-
62-
const weight = of(70, 72, 76, 79, 75);
63-
const height = of(1.76, 1.77, 1.78);
64-
const bmi = weight.pipe(
65-
combineLatest(height, (w, h) => w / (h * h))
66-
);
67-
/*
68-
Output:
69-
BMI is 24.212293388429753
70-
BMI is 23.93948099205209
71-
BMI is 23.671253629592222
72-
*/
73-
bmi.subscribe(x => console.log('BMI is ' + x));
74-
`,
75-
externalLink: {
76-
platform: 'JSBin',
77-
url: 'http://jsbin.com/pivowunedu/1/embed?js,console'
78-
}
79+
code: EXAMPLE_CODE
7980
}
8081
],
8182
relatedOperators: ['combineAll', 'merge', 'withLatestFrom'],

src/operator-docs/combination/concat.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,7 @@ export const concat: OperatorDoc = {
9191
});
9292
9393
// results in:
94-
// 0 -1000ms-> 1 -1000ms-> 2 -1000ms-> 3 -immediate-> 1 ... 10`,
95-
externalLink: {
96-
platform: 'JSBin',
97-
url: 'http://jsbin.com/doqoyimaxu/embed?js,console'
98-
}
94+
// 0 -1000ms-> 1 -1000ms-> 2 -1000ms-> 3 -immediate-> 1 ... 10`
9995
},
10096
{
10197
name: 'Concatenate an array of 3 Observables',
@@ -117,11 +113,7 @@ export const concat: OperatorDoc = {
117113
// -1000ms-> 0 -1000ms-> 1 -1000ms-> ... 9
118114
// -2000ms-> 0 -2000ms-> 1 -2000ms-> ... 5
119115
// -500ms-> 0 -500ms-> 1 -500ms-> ... 9
120-
`,
121-
externalLink: {
122-
platform: 'JSBin',
123-
url: 'http://jsbin.com/decaromone/1/embed?js,console'
124-
}
116+
`
125117
}
126118
],
127119
relatedOperators: ['concatAll', 'concatMap', 'concatMapTo']

src/operator-docs/combination/concatAll.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,7 @@ export const concatAll: OperatorDoc = {
5252
);
5353
const firstOrder = higherOrder.pipe(concatAll());
5454
firstOrder.subscribe(x => console.log(x));
55-
`,
56-
externalLink: {
57-
platform: 'JSBin',
58-
url: 'http://jsbin.com/guhefeyahi/embed?js,console,output'
59-
}
55+
`
6056
}
6157
],
6258
relatedOperators: [

src/operator-docs/combination/forkJoin.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,7 @@ export const forkJoin: OperatorDoc = {
8888
// Logs:
8989
// [4, 8]
9090
// "This is how it ends!"
91-
`,
92-
externalLink: {
93-
platform: 'JSBin',
94-
url: 'http://jsbin.com/kinilaruki/1/embed?js,console'
95-
}
91+
`
9692
},
9793
{
9894
name: 'Use forkJoin with operator emitting after some time',
@@ -113,11 +109,7 @@ export const forkJoin: OperatorDoc = {
113109
// Logs:
114110
// [2, 3] after 3 seconds
115111
// "This is how it ends!" immediately after
116-
`,
117-
externalLink: {
118-
platform: 'JSBin',
119-
url: 'http://jsbin.com/rewivubuqi/1/embed?js,console'
120-
}
112+
`
121113
},
122114
{
123115
name: 'Use forkJoin with project function',
@@ -135,11 +127,7 @@ export const forkJoin: OperatorDoc = {
135127
// Logs:
136128
// 5 after 3 seconds
137129
// "This is how it ends!" immediately after
138-
`,
139-
externalLink: {
140-
platform: 'JSBin',
141-
url: 'http://jsbin.com/wayomumike/1/embed?js,console'
142-
}
130+
`
143131
}
144132
],
145133
relatedOperators: ['combineLatest', 'zip']

src/operator-docs/combination/merge.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,7 @@ export const merge: OperatorDoc = {
5454
const timer = interval(1000);
5555
const clicksOrTimer = clicks.pipe(merge(timer));
5656
clicksOrTimer.subscribe(x => console.log(x));
57-
`,
58-
externalLink: {
59-
platform: 'JSBin',
60-
url: 'http://jsbin.com/wihafapiva/1/embed?js,output'
61-
}
57+
`
6258
},
6359
{
6460
name: 'Merge together 3 Observables, but only 2 run concurrently',
@@ -73,11 +69,7 @@ export const merge: OperatorDoc = {
7369
const concurrent = 2; // the argument
7470
const merged = timer1.pipe(merge(timer2, timer3, concurrent));
7571
merged.subscribe(x => console.log(x));
76-
`,
77-
externalLink: {
78-
platform: 'JSBin',
79-
url: 'http://jsbin.com/midosuqaga/1/embed?js,output'
80-
}
72+
`
8173
}
8274
],
8375
relatedOperators: ['mergeAll', 'mergeMap', 'mergeMapTo', 'mergeScan']

src/operator-docs/combination/mergeAll.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,7 @@ export const mergeAll: OperatorDoc = {
4646
const higherOrder = clicks.pipe(map((ev) => interval(1000)));
4747
const firstOrder = higherOrder.pipe(mergeAll());
4848
firstOrder.subscribe(x => console.log(x));
49-
`,
50-
externalLink: {
51-
platform: 'JSBin',
52-
url: 'http://jsbin.com/lebidefocu/1/embed?js,output'
53-
}
49+
`
5450
},
5551
{
5652
name:
@@ -66,11 +62,7 @@ export const mergeAll: OperatorDoc = {
6662
);
6763
const firstOrder = higherOrder.pipe(mergeAll(2));
6864
firstOrder.subscribe(x => console.log(x));
69-
`,
70-
externalLink: {
71-
platform: 'JSBin',
72-
url: 'http://jsbin.com/kokezoribu/embed?js,output'
73-
}
65+
`
7466
}
7567
],
7668
relatedOperators: [

src/operator-docs/combination/pairwise.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,7 @@ export const pairwise: OperatorDoc = {
4545
})
4646
);
4747
distance.subscribe(x => console.log(x));
48-
`,
49-
externalLink: {
50-
platform: 'JSBin',
51-
url: 'http://jsbin.com/wenazagegu/embed?js,console,output'
52-
}
48+
`
5349
}
5450
],
5551
relatedOperators: ['buffer', 'bufferCount']

src/operator-docs/combination/withLatestFrom.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,7 @@ export const withLatestFrom: OperatorDoc = {
4141
);
4242
const firstOrder = higherOrder.pipe(concatAll());
4343
firstOrder.subscribe(x => console.log(x));
44-
`,
45-
externalLink: {
46-
platform: 'JSBin',
47-
url: 'http://jsbin.com/wojoqenitu/1/embed?js,console,output'
48-
}
44+
`
4945
}
5046
],
5147
relatedOperators: ['combineLatest']

src/operator-docs/creation/empty.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,7 @@ export const empty: OperatorDoc = {
3535
next: () => console.log('next'), // does not log anything
3636
complete: () => console.log('complete'), // logs 'complete'
3737
});
38-
`,
39-
externalLink: {
40-
platform: 'JSBin',
41-
url: 'http://jsbin.com/hojacunecu/1/embed?js,console,output'
42-
}
38+
`
4339
},
4440
{
4541
name: 'Observable emits initial value then completes',
@@ -52,11 +48,7 @@ export const empty: OperatorDoc = {
5248
next: (val) => console.log(\`next: \${val}\`), // logs 'next: initial value'
5349
complete: () => console.log('complete'), // logs 'complete'
5450
});
55-
`,
56-
externalLink: {
57-
platform: 'JSBin',
58-
url: 'http://jsbin.com/tubonoradi/1/embed?js,console,output'
59-
}
51+
`
6052
},
6153
{
6254
name: `Map and flatten only odd numbers to the sequence 'ax', 'bx', 'cx'`,
@@ -76,11 +68,7 @@ export const empty: OperatorDoc = {
7668
next: (x) => console.log(x), // logs result values
7769
complete: () => console.log('complete'), // logs 'complete'
7870
});
79-
`,
80-
externalLink: {
81-
platform: 'JSBin',
82-
url: 'http://jsbin.com/qazabojiri/embed?js,console,output'
83-
}
71+
`
8472
}
8573
],
8674
relatedOperators: ['create', 'of', 'throw']

0 commit comments

Comments
 (0)