Skip to content

Instantly share code, notes, and snippets.

🇺🇸
Out sick

hax0r webhacking

🇺🇸
Out sick
Block or report user

Report or block webhacking

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View rxjs-example-05.ts
import {from} from 'rxjs/internal/observable/from';
import {distinctUntilChanged} from 'rxjs/operators';
const source = [
{x: 1, y: 1},
{x: 1, y: 2},
{x: 3, y: 5},
{x: 6, y: 9},
{x: 2, y: 1},
{x: 3, y: 5},
View rxjs-example-04.ts
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),
View rxjs-example-03.ts
import {fromEvent} from 'rxjs/internal/observable/fromEvent';
import {interval} from 'rxjs/internal/observable/interval';
import {buffer, filter, map} from 'rxjs/operators';
let stream$ = fromEvent(document.getElementById('hit-me') as HTMLElement, 'click');
stream$
.pipe(
buffer(interval(3000)),
map((val: number[]) => val.length),
View rxjs-example-02.ts
import {fromEvent} from 'rxjs/internal/observable/fromEvent';
import {buffer, map} from 'rxjs/operators';
import {interval} from 'rxjs/internal/observable/interval';
let stream$ = fromEvent(document.getElementById('hit-me'), 'click');
stream$
.pipe(
buffer(interval(3000)),
map((val) => val.length)
)
View rxjs-example-01.ts
import {fromEvent} from 'rxjs/internal/observable/fromEvent';
const source$ = fromEvent(document.getElementById('hit-me'), 'click');
source$.subscribe((event: Event) => {
const currentClicked = ( event.currentTarget.getAttribute('number-of-clicked') ) ? event.currentTarget.getAttribute('number-of-clicked') : 1;
event.currentTarget.setAttribute('number-of-clicked', parseInt(currentClicked) + 1);
console.log(parseInt(currentClicked))
});
View replay-subject.example1.ts
const subject = new ReplaySubject(1 /* buffer size */);
View replay-subject.example.ts
import {ReplaySubject} from 'rxjs/internal/ReplaySubject';
const subject = new ReplaySubject(2 /* buffer size */);
subject.next('a');
subject.next('b');
subject.next('c');
const subscription = subject.subscribe((x: string) => {
console.log(`Next: ${x}`);
View behavior-subject.example.ts
/* Initialize with initial value of 42 */
import {BehaviorSubject} from 'rxjs/internal/BehaviorSubject';
const subject = new BehaviorSubject(42);
const subscription = subject.subscribe((x: number) => {
console.log(`Next: ${String(x)}`);
}, (error: Error) => {
console.log(`Error: ${error}`);
}, () => {
View async-subject.example.ts
import {AsyncSubject} from 'rxjs/internal/AsyncSubject';
let subject = new AsyncSubject;
let i = 0;
const handle = setInterval(() => {
subject.next(i);
if (++i > 3) {
subject.complete();
clearInterval(handle);
View example.serverless.functions.yml
functions:
hello:
handler: handler.hello
events:
- http:
path: hello
method: get
You can’t perform that action at this time.