Skip to content

Commit

Permalink
Update sherlock (#172)
Browse files Browse the repository at this point in the history
* proxy value pipe test

* update sherlock versions

* update sherlock version
  • Loading branch information
emielb authored Jun 24, 2021
1 parent 607a331 commit 5d82c4f
Show file tree
Hide file tree
Showing 7 changed files with 211 additions and 171 deletions.
2 changes: 2 additions & 0 deletions e2e/src/app.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ describe('workspace-project App', () => {
page.navigateTo();
const currentAutoCDTime = await page.getAutoCDClock();
const currentPipeTime = await page.getPipeClock();
const currentProxyPipeTime = await page.getProxyPipeClock();
await new Promise(resolve => setTimeout(resolve, 1000));
expect(page.getAutoCDClock()).not.toEqual(currentAutoCDTime);
expect(page.getPipeClock()).not.toEqual(currentPipeTime);
expect(page.getProxyPipeClock()).not.toEqual(currentProxyPipeTime);
});
});
6 changes: 5 additions & 1 deletion e2e/src/app.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ export class AppPage {
}

getPipeClock() {
return element.all(by.css('app-value-pipe time')).first().getText();
return element.all(by.css('app-value-pipe time.base-clock')).first().getText();
}

getProxyPipeClock() {
return element.all(by.css('app-value-pipe time.base-clock')).last().getText();
}
}
329 changes: 172 additions & 157 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-sherlock-dev",
"version": "2.1.0",
"version": "2.2.0",
"scripts": {
"start": "FORCE_COLOR=1 npm-run-all -l -p watch:*",
"watch:lib": "ng build @politie/ngx-sherlock --watch",
Expand All @@ -24,9 +24,9 @@
"@angular/platform-browser": "^10.2.5",
"@angular/platform-browser-dynamic": "^10.2.5",
"@angular/router": "^10.2.5",
"@politie/sherlock": "^3.1.0",
"@politie/sherlock-proxy": "^3.1.0",
"@politie/sherlock-rxjs": "^3.1.0",
"@politie/sherlock": "^3.3.0",
"@politie/sherlock-proxy": "^3.3.0",
"@politie/sherlock-rxjs": "^3.3.0",
"core-js": "^3.14.0",
"rxjs": "^6.6.7",
"tslib": "^2.0.0",
Expand All @@ -50,7 +50,7 @@
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"ng-packagr": "^12.0.5",
"ng-packagr": "^12.0.8",
"npm-run-all": "^4.1.5",
"protractor": "~7.0.0",
"rimraf": "^3.0.2",
Expand Down
7 changes: 4 additions & 3 deletions projects/politie/ngx-sherlock/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "@politie/ngx-sherlock",
"version": "2.1.0",
"version": "2.2.0",
"peerDependencies": {
"@angular/common": ">=6",
"@angular/core": ">=6",
"@politie/sherlock": ">=2.0.0-rc.0",
"@politie/sherlock-rxjs": ">=2.0.0-rc.0"
"@politie/sherlock": ">=3.3.0",
"@politie/sherlock-proxy": ">=3.3.0",
"@politie/sherlock-rxjs": ">=3.3.0"
},
"contributors": [
"Paco van der Linden <[email protected]>",
Expand Down
11 changes: 10 additions & 1 deletion src/app/clock.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Injectable, NgZone } from '@angular/core';
import { atom, PullDataSource, unwrap } from '@politie/sherlock';
import { atom, derive, PullDataSource, unwrap } from '@politie/sherlock';
import { ProxyDescriptor } from '@politie/sherlock-proxy';

class Clock extends PullDataSource<string> {
constructor(readonly interval = 1000, private readonly zone: NgZone) { super(); }
Expand Down Expand Up @@ -33,4 +34,12 @@ export class ClockService {
readonly intervalClock$ = this.interval$
.derive(interval => new Clock(interval, this.zone))
.derive(unwrap);

/** A Proxy version of the clock */
readonly proxyClock: any = new ProxyDescriptor().$create(derive(() => ({
base: this.baseClock$.get(),
interval: this.interval$.get(),
seconds: this.seconds$.get(),
intervalClock: this.intervalClock$.get(),
})));
}
17 changes: 13 additions & 4 deletions src/app/value-pipe/value-pipe.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
<h2>Using <code>value</code> pipe</h2>
<p>Time is: <time>{{ clock.baseClock$ | value }}</time> (updating every second)</p>
<p>Time is: <time class="base-clock">{{ clock.baseClock$ | value }}</time> (updating every second)</p>
<p>
<label for="interval">Interval: </label><input type="number" name="interval" id="interval" [ngModel]="clock.seconds$ | value" (ngModelChange)="clock.seconds$.value = $event">
seconds</p>
<p>Time is: <time>{{ clock.intervalClock$ | value }}</time> (updating every {{ clock.seconds$ | value }} second(s))</p>
<label for="interval">Interval: </label><input type="number" name="interval" id="interval" [ngModel]="clock.seconds$ | value"
(ngModelChange)="clock.seconds$.value = $event">
seconds
</p>
<p>Time is: <time>{{ clock.intervalClock$ | value }}</time> (updating every {{ clock.seconds$ | value }} second(s))</p>
<p>Proxy time is: <time class="base-clock">{{ clock.proxyClock.base | value }}</time> (updating every second)</p>
<p>
<label for="interval">Proxy interval: </label><input type="number" name="interval" id="interval" [ngModel]="clock.proxyClock.seconds | value"
(ngModelChange)="clock.proxyClock.seconds.value = $event">
seconds
</p>
<p>Proxy time is: <time>{{ clock.proxyClock.intervalClock | value }}</time> (updating every {{ clock.proxyClock.seconds | value }} second(s))</p>

0 comments on commit 5d82c4f

Please sign in to comment.