-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
This PR remove the session level resource change signal for a process level one. This allow changes to the resource coming from the data service to trigger UI updates. - Remove send sse from putResource and loadResource ops - Extend the UILayer to host a resource changes channel - Feed the UILayer channel with changes from the resource via an observer thread ADP-3451
- Loading branch information
Showing
12 changed files
with
106 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
lib/customer-deposit-wallet/src/Cardano/Wallet/Deposit/IO/Resource/Event.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
module Cardano.Wallet.Deposit.IO.Resource.Event | ||
( onResourceChange | ||
) where | ||
|
||
import Prelude | ||
|
||
import Cardano.Wallet.Deposit.IO.Resource | ||
( Resource | ||
, ResourceStatus (..) | ||
, readStatus | ||
) | ||
import Control.Concurrent.Async | ||
( withAsync | ||
) | ||
import Control.Concurrent.Class.MonadSTM | ||
( MonadSTM (..) | ||
, atomically | ||
) | ||
import Control.Monad | ||
( void | ||
) | ||
import Control.Monad.Cont | ||
( ContT (..) | ||
) | ||
import Control.Monad.Fix | ||
( fix | ||
) | ||
|
||
-- | Run an action whenever the status of a 'Resource' changes. | ||
onResourceChange | ||
:: (ResourceStatus e a -> IO ()) | ||
-> Resource e a | ||
-> ContT x IO () | ||
onResourceChange f resource = do | ||
void $ ContT $ withAsync $ ($ Closed) $ fix $ \loop lastStatus -> do | ||
status <- atomically $ do | ||
status <- readStatus resource | ||
case (status, lastStatus) of | ||
(Closed, Closed) -> retry | ||
(Opening, Opening) -> retry | ||
(Open _a, Open _a') -> retry -- this is something to think about | ||
(FailedToOpen _e, FailedToOpen _e') -> retry | ||
(Vanished _e, Vanished _e') -> retry | ||
(Closing, Closing) -> retry | ||
_ -> pure () | ||
pure status | ||
f status | ||
loop status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,6 +115,7 @@ library | |
, random | ||
, servant | ||
, servant-server | ||
, stm | ||
, string-interpolate | ||
, text | ||
, text-class | ||
|
Oops, something went wrong.