Skip to content

fix: using Hub category to fire configured event #3995

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Amplify/Core/Configuration/AmplifyConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ extension Amplify {
static func notifyAllHubChannels() {
let payload = HubPayload(eventName: HubPayload.EventName.Amplify.configured)
for channel in HubChannel.amplifyChannels {
Hub.plugins.values.forEach { $0.dispatch(to: channel, payload: payload) }
Task {
Amplify.Hub.dispatch(to: channel, payload: payload)
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion AmplifyTestCommon/Mocks/MockHubCategoryPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class MockHubCategoryPlugin: MessageReporter, HubCategoryPlugin {
}

func dispatch(to channel: HubChannel, payload: HubPayload) {
notify("dispatch")
notify("\(payload.eventName)")
}

func listen(to channel: HubChannel,
Expand Down
2 changes: 1 addition & 1 deletion AmplifyTests/CategoryTests/Hub/HubClientAPITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class HubClientAPITests: XCTestCase {
}
}

Amplify.Hub.dispatch(to: .storage, payload: HubPayload(eventName: ""))
Amplify.Hub.dispatch(to: .storage, payload: HubPayload(eventName: "dispatch"))

await fulfillment(of: [methodWasInvokedOnPlugin], timeout: 0.5)
}
Expand Down
Loading