-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from alexmt/bug-fixes
UI Bug fixes
- Loading branch information
Showing
6 changed files
with
116 additions
and
11 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import * as moment from 'moment'; | ||
import * as React from 'react'; | ||
import {Observable, Subscription} from 'rxjs'; | ||
|
||
export class Ticker extends React.Component<{intervalMs?: number, children?: ((time: moment.Moment) => React.ReactNode)}, {time: moment.Moment}> { | ||
|
||
private subscription: Subscription; | ||
|
||
constructor(props: {intervalMs?: number, children?: ((time: moment.Moment) => React.ReactNode)}) { | ||
super(props); | ||
this.state = { time: moment() }; | ||
this.subscription = Observable.interval(props.intervalMs || 1000).subscribe(() => this.setState({ time: moment() })); | ||
} | ||
|
||
public render() { | ||
return this.props.children(this.state.time); | ||
} | ||
|
||
public componentWillUnmount() { | ||
if (this.subscription != null) { | ||
this.subscription.unsubscribe(); | ||
this.subscription = null; | ||
} | ||
} | ||
} |
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