Skip to content

Commit

Permalink
Fix onConsume (#470)
Browse files Browse the repository at this point in the history
  • Loading branch information
muukii authored Mar 23, 2024
1 parent 419af19 commit 7a79947
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Sources/Verge/Library/EventEmitter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ open class EventEmitter<Event: EventEmitterEventType>: EventEmitterType, @unchec

for subscriber in capturedSubscribers {
subscriber.1(event)
event.onComsume()
}
event.onComsume()
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Sources/Verge/Store/Store.swift
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ extension Store {
extension Store {

public func waitUntilAllEventConsumed() async {
await withUnsafeContinuation { c in
await withCheckedContinuation { c in
accept(.waiter({
c.resume()
}))
Expand Down
5 changes: 3 additions & 2 deletions Tests/VergeTests/StoreAndDerivedTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ final class StoreAndDerivedTests: XCTestCase {
}
}


XCTAssertEqual(store.state.count, 100)

await store.waitUntilAllEventConsumed()
// potentially it fails as EventEmitter's behavior
// If EventEmitter's buffer is not empty, commit function escape from the stack by only adding.
// XCTAssertEqual(countDerived.state.primitive, 100)
XCTAssertNotEqual(countDerived.state.primitive, 100)
XCTAssertEqual(countDerived.state.primitive, 100)
}

}
Expand Down

0 comments on commit 7a79947

Please sign in to comment.