Skip to content

Commit d5ef34f

Browse files
committedMay 17, 2018
feat(clock): rename register to tick
1 parent e2f64ac commit d5ef34f

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed
 

‎README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,15 @@ export class AppModule { }
174174

175175
#### Write your own clock
176176

177-
The only required method to build your own clock, is `register` that must return an `Observable<any>`. Whenever this observable emits, the timestamp will be updated, using your formatter (and intl, if available).
177+
The only required method to build your own clock, is `tick` that must return an `Observable<any>`. Whenever this observable emits, the timestamp will be updated, using your formatter (and intl, if available).
178178

179179
```ts
180180
import { TimeagoClock } from 'ngx-timeago';
181181
import { Observable, interval } from 'rxjs';
182182

183183
// ticks every 2s
184184
export class MyClock extends TimeagoClock {
185-
register(then: number): Observable<number> {
185+
tick(then: number): Observable<number> {
186186
return interval(2000);
187187
}
188188
}

‎demo/app/app.module.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { AppComponent } from './app.component';
1010
import { AppRoutingModule } from './app-routing.module';
1111

1212
export class MyClock extends TimeagoClock {
13-
register(then: number): Observable<number> {
13+
tick(then: number): Observable<number> {
1414
return of(0)
1515
.pipe(
1616
expand(() => {

‎lib/src/timeago.clock.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import { expand, delay, skip } from 'rxjs/operators';
44
import { MINUTE, HOUR, DAY, WEEK, MONTH, YEAR } from './util';
55

66
export abstract class TimeagoClock {
7-
abstract register(then: number): Observable<any>;
7+
abstract tick(then: number): Observable<any>;
88
}
99

1010
@Injectable()
1111
export class TimeagoDefaultClock extends TimeagoClock {
12-
register(then: number): Observable<number> {
12+
tick(then: number): Observable<number> {
1313
return of(0)
1414
.pipe(
1515
expand(() => {

‎lib/src/timeago.directive.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class TimeagoDirective implements OnChanges, OnDestroy {
4040
if (this.clockSubscription) {
4141
this.clockSubscription.unsubscribe();
4242
}
43-
this.clockSubscription = this.clock.register(date)
43+
this.clockSubscription = this.clock.tick(date)
4444
.pipe(filter(() => this.live, this))
4545
.subscribe(() => this.stateChanges.next());
4646
} else {

‎tests/clock.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('TimeagoClock', () => {
2222

2323
it('should complete instantly for differences greater than a day', (() => {
2424
testScheduler.run(({ expectObservable }) => {
25-
const source = clock.register(Date.now() - 60 * 60 * 24 * 1000).pipe(map(x => x.toString()));
25+
const source = clock.tick(Date.now() - 60 * 60 * 24 * 1000).pipe(map(x => x.toString()));
2626
const expected = '|';
2727
expectObservable(source).toBe(expected);
2828
});

0 commit comments

Comments
 (0)
Please sign in to comment.