A services router decoupling modules base on service name.
Objective-C Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
example
source
.gitignore
.swift-version
FMServicesRouter.podspec
LICENSE
README.md

README.md

FMServicesRouter

A services router decoupling modules base on service name.

Installation

With CocoaPods, add this line to your Podfile.

pod 'FMServicesRouter'

and run pod install, then you're all done!

Or copy *.h *.m files in source folder to your project.

How to use

  • Implement FMServicesRouterServiceProtocol in service.
/**
 * Farword client call to service.
 */
- (void)calledWithParams:(NSDictionary *)params
               successed:(void(^)(NSDictionary *responseObj))successed
                  failed:(void(^)(NSError *error))failed {
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        dispatch_async(dispatch_get_main_queue(), ^{
            if (successed) {
                successed(@{@"result" : @"hello world!"});
            }
        });
    });
}
  • Register
    [[FMServicesRouter sharedInstance] registerServiceInstance:[CustomService new] withName:@"custom.service"];

  • Call in client
    if ([[FMServicesRouter sharedInstance] callService:@"custom.service" withParams:nil successed:^(NSDictionary *responseObj) {
        NSLog(@"Service response success : %@", responseObj);
    } failed:^(NSError *error) {
        NSLog(@"Service response failed.");
    }]) {
        NSLog(@"Call service success.");
    } else {
        NSLog(@"Call service failed.");
    }

Requirements

  • iOS 7.0+
  • ARC

License

  • MIT