File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 1
1
import * as Effect from "@effect/io/Effect"
2
+ import * as Exit from "@effect/io/Exit"
2
3
import * as Fiber from "@effect/io/Fiber"
3
4
import * as Ref from "@effect/io/Ref"
4
5
import * as Runtime from "@effect/io/Runtime"
@@ -58,13 +59,18 @@ export const makeUseResultCallback: <R>(
58
59
} )
59
60
)
60
61
61
- const fiber = Effect . sync ( ( ) => {
62
+ const fiber = Stream . suspend ( ( ) => {
62
63
setResult ( ( prev ) => updateNext ( Result . waiting ( prev ) , trackRef ) )
64
+ return f ( ...args )
63
65
} ) . pipe (
64
- Stream . flatMap ( ( ) => f ( ...args ) ) ,
65
66
Stream . tap ( ( value ) => maybeSetResult ( updateNext ( Result . success ( value ) , trackRef ) ) ) ,
66
67
Stream . tapErrorCause ( ( cause ) => maybeSetResult ( updateNext ( Result . failCause ( cause ) , trackRef ) ) ) ,
67
68
Stream . runDrain ,
69
+ Effect . onExit ( ( exit ) =>
70
+ Exit . isInterrupted ( exit )
71
+ ? Effect . unit
72
+ : Effect . sync ( ( ) => setFiberState ( { _tag : "Idle" } ) )
73
+ ) ,
68
74
Runtime . runFork ( runtime )
69
75
)
70
76
You can’t perform that action at this time.
0 commit comments