-
Notifications
You must be signed in to change notification settings - Fork 311
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
Multiple Message Passing Implementation #100
base: master
Are you sure you want to change the base?
Conversation
|
||
#pragma mark - MMWormholeTransiting Methods | ||
|
||
- (BOOL)writeMessageObject:(id<NSCoding>)messageObject forIdentifier:(NSString *)identifier { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you want to pass in an error pointer to find out how it might have failed?
} else { | ||
storageArray = [[NSMutableArray alloc] init]; | ||
} | ||
[storageArray addObject:messageObject]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a concern that we are storing a reference to the messageObject
and someone might later mutate the message? Do we want to prefer a copy of the object here?
if ([storageArray count] == 0) { | ||
return nil; | ||
} | ||
id messageObject = storageArray[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems curious that we are making the assumption the array returned for this identifier
is always a single item collection. Why are we writing and reading arrays from the file system and not the message object itself?
NSError *error = nil; | ||
__block NSData *data = nil; | ||
|
||
[fileCoordinator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems expensive to read from disk for every call, though I'd probably just make a note of the consideration until it's a measurable issue.
Hello folks! Seems like this library is mostly unmaintained but I figured I'd open this PR for posterity sake incase anyone else needs this.
Issue
The default
MMWormholeFileTransiting
and its subclassMMWormholeCoordinatedFileTransiting
both have an inherent issue where they support enqueuing multiple messages across the wormhole, BUT every time a message is enqueued, it overwrites the message payload. So, when attempting to transitN
message payloads across the wormhole (similar to howNSNotificationCenter
or any other message bus construct works), you getN
messages but only the latest written payload.Solution
This doesn't work for my use case unfortunately, so thus I present
MMWormholeManifestFileTransiting
for your inspection and approval. It utilizes the more modern NSFileCoordinator-based approach fromMMWormholeCoordinatedFileTransiting
but instead of just writing the message to disk and thus overwriting whatever is currently there, it manages a stack (NSArray
) of messages that need to be sent across the wormhole which are then dispatched FILO style across the wormhole via pushing and popping the stack.There's a few potential improvements / optimizations to be made here: