Skip to content

Commit 1d61e4f

Browse files
committed
fix(queue): fix queue not removing the element immediately for dispatching
1 parent 48d45e5 commit 1d61e4f

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

src/main/Queue.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ export class Queue<A = never> {
100100
)
101101
)
102102

103-
return itar(List.empty<UIO<boolean>>()).chain(_ =>
104-
FIO.seq(_.asArray).tap(() => (!_.isEmpty ? this.Q.shift : FIO.void()))
105-
)
103+
return itar(List.empty<UIO<boolean>>())
104+
.tap(_ => (!_.isEmpty ? this.Q.shift : FIO.void()))
105+
.chain(_ => FIO.seq(_.asArray))
106106
}
107107

108108
/**

test/FStream.test.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import {FIO} from '../src/main/FIO'
55
import {FStream} from '../src/main/FStream'
66
import {testRuntime} from '../src/runtimes/TestRuntime'
77

8+
import {Snapshot} from './internals/Snapshot'
9+
810
describe('FStream', () => {
911
describe('of', () => {
1012
it('should emit provided values', () => {
@@ -52,14 +54,19 @@ describe('FStream', () => {
5254
})
5355

5456
describe('merge', () => {
55-
it.skip('should merge two streams', () => {
56-
const actual = testRuntime().unsafeExecuteSync(
57-
FStream.of(1)
58-
.merge(FStream.of(2))
59-
.fold(new Array<number>(), () => true, (s, a) => FIO.of([...s, a]))
57+
it('should merge two streams', () => {
58+
const actual = new Snapshot()
59+
const runtime = testRuntime()
60+
61+
runtime.unsafeExecuteSync(
62+
FStream.of('A')
63+
.merge(FStream.of('B'))
64+
.forEach(_ => actual.mark(_))
65+
.provide({runtime})
6066
)
61-
const expected = [1, 2]
62-
assert.deepStrictEqual(actual, expected)
67+
68+
const expected = ['A@1', 'B@1']
69+
assert.deepStrictEqual(actual.timeline, expected)
6370
})
6471
})
6572

0 commit comments

Comments
 (0)