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
class AmountInput { | |
private static MAX_ALLOWED = 99_999_999; | |
amount: number = 0; | |
showTooltip() { | |
//show tooltip | |
setTimeout(() => { | |
//hide tooltip | |
}, 2_500); |
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 React from "react"; | |
function Results() { | |
return ( | |
<table> | |
<tr> | |
<th> Title </th> | |
<th> First name </th> | |
<th> Surname </th> | |
<th> Email </th> |
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
class Book { | |
title: string; | |
} | |
class Television { | |
screenSize: string; | |
} | |
function relaxWith(item: Book | Television) { | |
if(item instanceof Book) { |
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
class MyService3 { | |
constructor() { | |
this._producer = Rx.Observable.of(1) | |
.publish(); | |
} | |
private _producer: Rx.ConnectableObservable<number>; | |
startItUp(): Rx.Observable<number> { |
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
class MyService { | |
constructor() { | |
this._producer = Rx.Observable.of(1) | |
.publish(); | |
} | |
private _producer: Rx.ConnectableObservable<number>; | |
startItUp(): Rx.Observable<number> { |
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
class MyService { | |
constructor() { | |
this._producer = Rx.Observable.interval(1000) | |
.publish(); | |
} | |
private _producer: Rx.ConnectableObservable<number>; | |
startItUp(): Rx.Observable<number> { |
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
function delayedRefCount(delay) { | |
return (source) => { | |
const subscribeUpdates = new Subject(); | |
let trackerConnection; | |
let subscriptionTracker = subscribeUpdates.scan((total, change) => change + total, 0) | |
.switchMap(count => { | |
return count === 0 | |
? Observable.timer(delay) | |
.do(_ => source.connect().unsubscribe() || trackerConnection.unsubscribe()) | |
: Observable.never(); |
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
subscribeUpdates | |
.scan((total, change) => change + total, 0) | |
.switchMap(count => { | |
return count === 0 | |
? Observable.timer(delay) | |
.do(_ => /* tear-down logic */ ) | |
: Observable.never(); | |
}); |
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
function delayedRefCount(delay) { | |
return (source) => { | |
let length = 0; | |
let timeout; | |
const onNewSubscriber = () => { | |
const onUnsubscribe = () => { | |
length--; | |
if (length === 0) { | |
timeout = setTimeout(() => { | |
source.connect().unsubscribe(); |
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
function refCount(source) { | |
let length = 0; | |
const onNewSubscriber = () => { | |
const onUnsubscribe = () => { | |
length--; | |
if(length === 0) { | |
source.connect().unsubscribe(); | |
} | |
}; | |
length++; |