Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
b17967e0
Commit
b17967e0
authored
Jun 07, 2019
by
Dominik Prokop
Committed by
Torkel Ödegaard
Jun 07, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RefreshPicker: SetInterval comments to rxjs code added (#17404)
parent
1aadb442
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
1 deletions
+17
-1
packages/grafana-ui/src/components/SetInterval/SetInterval.tsx
+17
-1
No files found.
packages/grafana-ui/src/components/SetInterval/SetInterval.tsx
View file @
b17967e0
...
...
@@ -23,17 +23,33 @@ export class SetInterval extends PureComponent<Props> {
}
componentDidMount
()
{
// Creating a subscription to propsSubject. This subject pushes values every time
// SetInterval's props change
this
.
subscription
=
this
.
propsSubject
.
pipe
(
// switchMap creates a new observables based on the input stream,
// which becomes part of the propsSubject stream
switchMap
(
props
=>
{
// If the query is live, empty value is emited. `of` creates single value,
// which is merged to propsSubject stream
if
(
isLive
(
props
.
interval
))
{
return
of
({});
}
// When query is loading, a new stream is merged. But it's a stream that emits no values(NEVER),
// hence next call of this function will happen when query changes, and new props are passed into this component
// When query is NOT loading, a new value is emited, this time it's an interval value,
// which makes tap function below execute on that interval basis.
return
props
.
loading
?
NEVER
:
interval
(
stringToMs
(
props
.
interval
));
}),
// tap will execute function passed via func prop
// * on value from `of` stream merged if query is live
// * on specified interval (triggered by values emited by interval)
tap
(()
=>
this
.
props
.
func
())
)
.
subscribe
();
// When component has mounted, propsSubject emits it's first value
this
.
propsSubject
.
next
(
this
.
props
);
}
...
...
@@ -41,7 +57,7 @@ export class SetInterval extends PureComponent<Props> {
if
((
isLive
(
prevProps
.
interval
)
&&
isLive
(
this
.
props
.
interval
))
||
_
.
isEqual
(
prevProps
,
this
.
props
))
{
return
;
}
// if props changed, a new value is emited from propsSubject
this
.
propsSubject
.
next
(
this
.
props
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment