Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Conversation

@bparrishMines
Copy link
Contributor

@bparrishMines bparrishMines commented May 1, 2019

Description

iOS side of possible reformat of Firebase Performance plugin

Related Issues

Android: #1529
Dart: #1530

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate a breaking change in CHANGELOG.md and increment major revision).
  • No, this is not a breaking change.

@bparrishMines bparrishMines changed the title Perf rewrite ios [firebase_perfomance] iOS side of reformat of Firebase Performance May 1, 2019
@bparrishMines bparrishMines changed the title [firebase_perfomance] iOS side of reformat of Firebase Performance [firebase_perfomance][WIP] iOS side of reformat of Firebase Performance May 1, 2019
@bparrishMines bparrishMines changed the title [firebase_perfomance][WIP] iOS side of reformat of Firebase Performance [firebase_perfomance] iOS side of reformat of Firebase Performance May 1, 2019
@bparrishMines bparrishMines removed the WIP label May 1, 2019
@collinjackson collinjackson self-requested a review May 2, 2019 17:36
Copy link
Contributor

@collinjackson collinjackson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you may still be working on this but wanted to share a few bits of early feedback.

#import <Flutter/Flutter.h>

@interface FLTFirebasePerformancePlugin : NSObject <FlutterPlugin>
+ (void)addMethodHandler:(NSNumber *_Nonnull)handle
Copy link
Contributor

@collinjackson collinjackson May 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By splitting things into multiple files, you're exposing a lot more class and method surface area here than we were previously. This could become a maintenance burden in the future if people use these APIs and we have to worry about breaking them. I think we should try to make the classes/methods private. Perhaps move addMethodHandler to a file named FirebasePerformancePlugin+Internal.h.

It might also make sense to move FirebasePerformancePlugin.h into a Public/ subfolder, if you can get that to work with the build system, and that will make it more clear that all the other classes are not part of the public API.

See how Firebase CocoaPods are laid out for reference:

https://github.com/firebase/firebase-ios-sdk/tree/master/Functions/FirebaseFunctions

+ (void)registerWithRegistrar:(nonnull NSObject<FlutterPluginRegistrar> *)registrar {
}

+ (void)sharedInstanceWithCall:(FlutterMethodCall *)call result:(FlutterResult)result {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From an Objective-C developer perspective, I feel this name could be confusing. Normally in Objective-C sharedInstance would be an idempotent static method that returns a singleton instance of the class. Here, you're performing a non-idempotent allocation action and returning nothing. Also you're not doing anything with the result argument. Perhaps another name would make it more clear what's going on.


@interface FLTFirebasePerformancePlugin (Internal)
+ (void)addMethodHandler:(NSNumber *_Nonnull)handle
methodHandler:(id<FlutterPlugin> _Nonnull)handler;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure how I feel about using id<FlutterPlugin> as the type here. The empty registerWithRegistrar implementations feel like this is a hack that we wouldn't want to propagate to other plugins. These objects aren't really FlutterPlugins, they are proxied classes. It might be a good idea to define a protocol makes this clear, perhaps something we can re-use for other plugins in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking the same thing when I was implementing the iOS side. On Android, they are called MethodHandlers and don't have static methods.

I could create a separate protocol such as

@protocol MethodHandler
@required
- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result
@end


@interface FLTTrace : NSObject <MethodHandler>
@end

tearDownAll(() => completer.complete(null));

group('firebase_performance test driver', () {
// TODO(bparrishMines): Rewrite integration tests when iOS portion is written.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder to address this

@bparrishMines
Copy link
Contributor Author

Closing in favor of #1557

@bparrishMines bparrishMines deleted the perf_rewrite_ios branch May 14, 2019 20:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants