Created
January 24, 2019 04:57
-
-
Save webhacking/428bddff5908b762c457729662106568 to your computer and use it in GitHub Desktop.
RxJS Example 04
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
import {from} from 'rxjs/internal/observable/from'; | |
import {bufferCount, count, filter} from 'rxjs/operators'; | |
const source = 'acbqibekboabkdnopenmenuckofqamdqlvopenmenuasdqweascqwekasdcnaskdeqweqwcasdopenmenu'; | |
const sequence$ = from(source); | |
const matchSequence = 'openmenu'; | |
sequence$ | |
.pipe( | |
bufferCount(matchSequence.length, 1), | |
filter((x) => { | |
return ( x.join('') === matchSequence ) | |
}), | |
count(), | |
) | |
.subscribe((cnt: number) => { | |
console.log(cnt) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment