-
-
Notifications
You must be signed in to change notification settings - Fork 595
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/handle multithreaded notifications (#1051)
* Be more careful about threading and notifications Make sure that Nimble doesn't try to access notification properties from the main thread as they may have been created on another thread and get upset (most likely when Core Data is involved). Fixes #973 * Fix typo in CONTRIBUTING.md file * Update Tests/NimbleTests/Helpers/BackgroundThreadObject.swift Co-authored-by: Rachel Brindle <[email protected]> * Fix tests for PostNotificationTest --------- Co-authored-by: John McKerrell <[email protected]>
- Loading branch information
1 parent
d605306
commit 605d2bd
Showing
5 changed files
with
69 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Foundation | ||
import Nimble | ||
|
||
// Simulates an object that *really* cares what thread it is run on. | ||
// Supposed to replicate what happens if a NSManagedObject ends up | ||
// in a notification and is picked up by Nimble | ||
class BackgroundThreadObject: CustomDebugStringConvertible { | ||
var debugDescription: String { | ||
if Thread.isMainThread { | ||
fail("This notification was accessed on the main thread when it should have been handled on the thread it was received on") | ||
} | ||
return "BackgroundThreadObject" | ||
} | ||
} |
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