Skip to content

Commit 99cad28

Browse files
authored
Add poll-interval attribute (#992)
1 parent 65624e5 commit 99cad28

File tree

9 files changed

+85
-22
lines changed

9 files changed

+85
-22
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project
66
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased]
9+
10+
### Added
11+
12+
- Added `poll-interval` prop to `<manifold-resource-list>`, `<manifold-data-resource-list>`, and
13+
`<manifold-data-has-resource>`.
14+
815
## [0.9.8] - 2020-03-30
916

1017
### Fixed
@@ -543,6 +550,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
543550
- Changed the `manifold-resource-credentials` component to use the standalone `manifold-credentials`
544551
component.
545552

553+
[unreleased]: https://github.com/manifoldco/ui/compare/v0.9.8...HEAD
546554
[0.9.8]: https://github.com/manifoldco/ui/compare/v0.9.7...v0.9.8
547555
[0.9.7]: https://github.com/manifoldco/ui/compare/v0.9.6...v0.9.7
548556
[0.9.6]: https://github.com/manifoldco/ui/compare/v0.9.5...v0.9.6

docs/docs/components/manifold-resource-list.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,27 @@ To navigate using a traditional `<a>` tag, specify a `resource-link-format` attr
1818
`:resource` as a placeholder:
1919

2020
```html
21-
<manifold-data-resource-list
22-
resource-link-format="/resource/:resource"
23-
></manifold-data-resource-list>
21+
<manifold-resource-list resource-link-format="/resource/:resource"></manifold-resource-list>
2422
```
2523

2624
Note that this will disable the custom event unless `preserve-event` is passed as well.
2725

26+
## Polling interval
27+
28+
This will change the polling interval from `3000 ms` (3 seconds, default) to `10000 ms` (10
29+
seconds):
30+
31+
```html
32+
<manifold-resource-list poll-interval="10000"></manifold-resource-list>
33+
```
34+
2835
## Pausing updates
2936

3037
By default, this component will subscribe to updates from the server. To disable that, pass the
3138
`paused` attribute:
3239

3340
```html
34-
<manifold-data-resource-list paused></manifold-data-resource-list>
41+
<manifold-resource-list paused></manifold-resource-list>
3542
```
3643

3744
## Loading state
@@ -59,7 +66,7 @@ You can pass in your own "no resources" state for the componenent by passing in
5966

6067
## Context (team, org, etc.)
6168

62-
To filter the resource list by an owner-id that provides a different context than just the user
69+
To filter the resource list by an owner-id that provides a different context than just the user
6370
context (e.g. team resources), you can provide the owner-id to filter by:
6471

6572
```html

docs/docs/data/manifold-data-has-resource.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ resources provisioned other than the one specfied).
3737
</manifold-data-has-resource>
3838
```
3939

40+
## Polling interval
41+
42+
This will change the polling interval from `3000 ms` (3 seconds, default) to `10000 ms` (10
43+
seconds):
44+
45+
```html
46+
<manifold-data-has-resource poll-interval="10000"></manifold-data-has-resource>
47+
```
48+
4049
## Pausing updates
4150

4251
By default, this component will subscribe to updates from the server and make periodic requests. To

docs/docs/data/manifold-data-resource-list.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ To navigate using a traditional `<a>` tag (which would cause a full-page refresh
5555
Note that specifying this attribute will disable the custom event unless `preserve-event` is passed
5656
as well.
5757

58+
## Polling interval
59+
60+
This will change the polling interval from `3000 ms` (3 seconds, default) to `10000 ms` (10
61+
seconds):
62+
63+
```html
64+
<manifold-data-resource-list poll-interval="10000"></manifold-data-resource-list>
65+
```
66+
5867
## Pausing updates
5968

6069
By default, this component will subscribe to updates from the server (in case users add a new
@@ -67,7 +76,7 @@ attribute:
6776

6877
## Context (team, org, etc.)
6978

70-
To filter the resource list by an owner-id that provides a different context than just the user
79+
To filter the resource list by an owner-id that provides a different context than just the user
7180
context (e.g. team resources), you can provide the owner-id to filter by:
7281

7382
```html

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"clean-package-json": "node scripts/clean-package-json",
3030
"copy-changelog": "node scripts/copy-changelog",
3131
"dev": "npm run build:watch & rm -rf dist && wait-on dist/loader/index.cjs.js && npm run storybook",
32-
"docs": "npm run prepare:docs && cd docs && npm start",
32+
"docs": "make package && npm run copy-changelog && cd docs && npm start",
3333
"docker": "docker build -t manifoldco/ui . && docker run -p 8080:80 manifoldco/ui",
3434
"format:changelog": "npx keep-a-changelog && prettier CHANGELOG.md --write",
3535
"generate:gql": "graphql-codegen --config codegen.yml",

src/components.d.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ export namespace Components {
150150
'label'?: string;
151151
'ownerId'?: string;
152152
'paused'?: boolean;
153+
/**
154+
* Adjust poll frequency
155+
*/
156+
'pollInterval'?: number;
153157
}
154158
interface ManifoldDataProductLogo {
155159
/**
@@ -260,6 +264,10 @@ export namespace Components {
260264
*/
261265
'paused'?: boolean;
262266
/**
267+
* Interval at which this component polls
268+
*/
269+
'pollInterval'?: number;
270+
/**
263271
* Should the JS event still fire, even if product-link-format is passed?
264272
*/
265273
'preserveEvent'?: boolean;
@@ -571,6 +579,10 @@ export namespace Components {
571579
*/
572580
'paused'?: boolean;
573581
/**
582+
* Interval at which this component polls
583+
*/
584+
'pollInterval'?: number;
585+
/**
574586
* Should the JS event still fire, even if product-link-format is passed?
575587
*/
576588
'preserveEvent'?: boolean;
@@ -1203,6 +1215,10 @@ declare namespace LocalJSX {
12031215
'onManifold-hasResource-load'?: (event: CustomEvent<any>) => void;
12041216
'ownerId'?: string;
12051217
'paused'?: boolean;
1218+
/**
1219+
* Adjust poll frequency
1220+
*/
1221+
'pollInterval'?: number;
12061222
}
12071223
interface ManifoldDataProductLogo {
12081224
/**
@@ -1325,6 +1341,10 @@ declare namespace LocalJSX {
13251341
*/
13261342
'paused'?: boolean;
13271343
/**
1344+
* Interval at which this component polls
1345+
*/
1346+
'pollInterval'?: number;
1347+
/**
13281348
* Should the JS event still fire, even if product-link-format is passed?
13291349
*/
13301350
'preserveEvent'?: boolean;
@@ -1648,6 +1668,10 @@ declare namespace LocalJSX {
16481668
*/
16491669
'paused'?: boolean;
16501670
/**
1671+
* Interval at which this component polls
1672+
*/
1673+
'pollInterval'?: number;
1674+
/**
16511675
* Should the JS event still fire, even if product-link-format is passed?
16521676
*/
16531677
'preserveEvent'?: boolean;

src/components/manifold-data-has-resource/manifold-data-has-resource.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,17 @@ export class ManifoldDataHasResource {
2525
@Prop() graphqlFetch?: GraphqlFetch = connection.graphqlFetch;
2626
/** Disable auto-updates? */
2727
@Prop() label?: string;
28+
/** Adjust poll frequency */
29+
@Prop() pollInterval?: number = 3000;
2830
@Prop() ownerId?: string;
2931
@Prop() paused?: boolean = false;
30-
@State() interval?: number;
32+
@State() poll?: number;
3133
@State() hasResource?: boolean;
3234
@Event({ eventName: 'manifold-hasResource-load', bubbles: true }) loadEvent: EventEmitter;
3335

3436
@Watch('paused') pausedChange(newPaused: boolean) {
3537
if (newPaused) {
36-
window.clearInterval(this.interval);
38+
window.clearInterval(this.poll);
3739
} else {
3840
this.makeInterval();
3941
}
@@ -48,13 +50,13 @@ export class ManifoldDataHasResource {
4850
}
4951

5052
componentDidUnload() {
51-
if (this.interval) {
52-
window.clearInterval(this.interval);
53+
if (this.poll) {
54+
window.clearInterval(this.poll);
5355
}
5456
}
5557

5658
makeInterval() {
57-
this.interval = window.setInterval(() => this.fetchResources(), 3000);
59+
this.poll = window.setInterval(() => this.fetchResources(), this.pollInterval);
5860
}
5961

6062
async fetchResources(label = this.label) {

src/components/manifold-data-resource-list/manifold-data-resource-list.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ export class ManifoldDataResourceList {
2828
@Prop() graphqlFetch?: GraphqlFetch = connection.graphqlFetch;
2929
/** Disable auto-updates? */
3030
@Prop() paused?: boolean = false;
31+
/** Interval at which this component polls */
32+
@Prop() pollInterval?: number = 3000;
3133
/** Link format structure, with `:resource` placeholder */
3234
@Prop() resourceLinkFormat?: string;
3335
/** Should the JS event still fire, even if product-link-format is passed? */
3436
@Prop() preserveEvent?: boolean = false;
3537
/** OwnerId to filter resources by */
3638
@Prop() ownerId?: string;
37-
@State() interval?: number;
39+
@State() poll?: number;
3840
@State() resources?: ResourceEdge[];
3941
@Event({ eventName: 'manifold-resourceList-click', bubbles: true }) clickEvent: EventEmitter;
4042

@@ -52,13 +54,13 @@ export class ManifoldDataResourceList {
5254
// start polling
5355
this.fetchResources();
5456
if (!this.paused) {
55-
this.interval = window.setInterval(() => this.fetchResources(), 3000);
57+
this.poll = window.setInterval(() => this.fetchResources(), this.pollInterval);
5658
}
5759
}
5860

5961
componentDidUnload() {
60-
if (this.interval) {
61-
window.clearInterval(this.interval);
62+
if (this.poll) {
63+
window.clearInterval(this.poll);
6264
}
6365
}
6466

src/components/manifold-resource-list/manifold-resource-list.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export class ManifoldResourceList {
1717
@Element() el: HTMLElement;
1818
/** _(hidden)_ */
1919
@Prop() graphqlFetch?: GraphqlFetch = connection.graphqlFetch;
20+
/** Interval at which this component polls */
21+
@Prop() pollInterval?: number = 3000;
2022
/** Disable auto-updates? */
2123
@Prop() paused?: boolean = false;
2224
/** Link format structure, with `:resource` placeholder */
@@ -25,14 +27,14 @@ export class ManifoldResourceList {
2527
@Prop() preserveEvent?: boolean = false;
2628
/** Filter resource list by ownerId */
2729
@Prop() ownerId?: string;
28-
@State() interval?: number;
30+
@State() poll?: number;
2931
@State() resources?: ResourceEdge[];
3032

3133
@Watch('paused') pausedChange(newPaused: boolean) {
3234
if (newPaused) {
33-
window.clearInterval(this.interval);
35+
window.clearInterval(this.poll);
3436
} else {
35-
this.interval = window.setInterval(() => this.fetchResources(), 3000);
37+
this.poll = window.setInterval(() => this.fetchResources(), this.pollInterval);
3638
}
3739
}
3840

@@ -50,13 +52,13 @@ export class ManifoldResourceList {
5052
// start polling
5153
this.fetchResources();
5254
if (!this.paused) {
53-
this.interval = window.setInterval(() => this.fetchResources(), 3000);
55+
this.poll = window.setInterval(() => this.fetchResources(), this.pollInterval);
5456
}
5557
}
5658

5759
componentDidUnload() {
58-
if (this.interval) {
59-
window.clearInterval(this.interval);
60+
if (this.poll) {
61+
window.clearInterval(this.poll);
6062
}
6163
}
6264

0 commit comments

Comments
 (0)