Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qbar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
jktr
qbar
Commits
43d8a408
Commit
43d8a408
authored
5 years ago
by
Jens Nolte
Browse files
Options
Downloads
Patches
Plain Diff
Fix schedulePullBlock to handle clicks while updating
parent
275d699b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/QBar/Core.hs
+11
-5
11 additions, 5 deletions
src/QBar/Core.hs
with
11 additions
and
5 deletions
src/QBar/Core.hs
+
11
−
5
View file @
43d8a408
...
...
@@ -164,7 +164,11 @@ defaultInterval = everyNSeconds 10
-- |Converts a 'PullBlock' to a 'PushBlock' by running it whenever the 'defaultInterval' is triggered.
schedulePullBlock
::
PullBlock
->
PushBlock
schedulePullBlock
pullBlock
=
PushMode
<$
pullBlock
>->
sleepToNextInterval
schedulePullBlock
=
schedulePullBlock'
defaultInterval
-- |Converts a 'PullBlock' to a 'PushBlock' by running it whenever the 'defaultInterval' is triggered.
schedulePullBlock'
::
Interval
->
PullBlock
->
PushBlock
schedulePullBlock'
interval
pullBlock
=
PushMode
<$
pullBlock
>->
sleepToNextInterval
where
sleepToNextInterval
::
Pipe
BlockUpdate
BlockUpdate
BarIO
PullMode
sleepToNextInterval
=
do
...
...
@@ -175,10 +179,10 @@ schedulePullBlock pullBlock = PushMode <$ pullBlock >-> sleepToNextInterval
then
do
-- If state already has an event handler, we do not attach another one
yield
(
state
,
PullUpdate
)
sleepUntilInterval
defaultI
nterval
sleepUntilInterval
i
nterval
else
do
-- Attach a click handler that will trigger a block update
yield
$
(
updateEventHandler
(
triggerOnClick
event
)
state
,
PullUpdate
)
yield
(
updateEventHandler
(
triggerOnClick
event
)
state
,
PullUpdate
)
scheduler
<-
askSleepScheduler
result
<-
liftIO
$
do
...
...
@@ -186,10 +190,12 @@ schedulePullBlock pullBlock = PushMode <$ pullBlock >-> sleepToNextInterval
eventTask
<-
async
$
Event
.
wait
event
waitEitherCancel
timerTask
eventTask
when
(
isRight
result
)
$
yield
$
(
invalidateBlockState
state
,
UserUpdate
)
when
(
isRight
result
)
$
do
liftIO
$
Event
.
clear
event
yield
(
invalidateBlockState
state
,
UserUpdate
)
triggerOnClick
::
Event
->
BlockEvent
->
BarIO
()
triggerOnClick
event
_
=
liftIO
$
Event
.
s
ignal
event
triggerOnClick
event
_
=
liftIO
$
Event
.
s
et
event
-- |Creates a new cache from a producer that automatically seals itself when the producer terminates.
newCache
::
Producer
[
BlockState
]
BarIO
()
->
BlockCache
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment