Commit 030f1738 authored by 余玠's avatar 余玠

get rid of the singleton function of FLBFlutterApplication

parent 6b9c1239
...@@ -111,26 +111,16 @@ ...@@ -111,26 +111,16 @@
return _instance; return _instance;
} }
- (id<FLBFlutterApplicationInterface>)application
{
return _application;
}
- (id<FLBAbstractFactory>)factory
{
return _factory;
}
- (void)startFlutterWithPlatform:(id<FLBPlatform>)platform - (void)startFlutterWithPlatform:(id<FLBPlatform>)platform
onStart:(void (^)(FlutterEngine *engine))callback; onStart:(void (^)(FlutterEngine *engine))callback;
{ {
static dispatch_once_t onceToken; static dispatch_once_t onceToken;
__weak __typeof__(self) weakSelf = self;
dispatch_once(&onceToken, ^{ dispatch_once(&onceToken, ^{
self->_factory = FLBFactory.new; __strong __typeof__(weakSelf) self = weakSelf;
self->_application = [self->_factory createApplication:platform]; self.factory = FLBFactory.new;
[self->_application startFlutterWithPlatform:platform self.application = [self->_factory createApplication:platform];
[self.application startFlutterWithPlatform:platform
onStart:callback]; onStart:callback];
}); });
} }
......
...@@ -26,14 +26,11 @@ ...@@ -26,14 +26,11 @@
#import "FLBFlutterApplicationInterface.h" #import "FLBFlutterApplicationInterface.h"
#import "FLBAbstractFactory.h" #import "FLBAbstractFactory.h"
#import "FlutterBoostPlugin.h" #import "FlutterBoostPlugin.h"
@interface FlutterBoostPlugin(){ @interface FlutterBoostPlugin()
id<FLBFlutterApplicationInterface> _application; @property (nonatomic,strong) id<FLBFlutterApplicationInterface> application;
id<FLBAbstractFactory> _factory; @property (nonatomic,strong) id<FLBAbstractFactory> factory;
}
@property (nonatomic,strong) FlutterMethodChannel *methodChannel; @property (nonatomic,strong) FlutterMethodChannel *methodChannel;
@property (nonatomic,copy) NSString *fPageId; @property (nonatomic,copy) NSString *fPageId;
@property (nonatomic,copy) NSString *fPagename; @property (nonatomic,copy) NSString *fPagename;
@property (nonatomic,strong) NSDictionary *fParams; @property (nonatomic,strong) NSDictionary *fParams;
- (id<FLBFlutterApplicationInterface>)application;
- (id<FLBAbstractFactory>)factory;
@end @end
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
- (id<FLBFlutterApplicationInterface>)createApplication:(id<FLBPlatform>)platform - (id<FLBFlutterApplicationInterface>)createApplication:(id<FLBPlatform>)platform
{ {
return [FLBFlutterApplication sharedApplication]; return [FLBFlutterApplication new];
} }
- (id<FLBFlutterContainer>)createFlutterContainer - (id<FLBFlutterContainer>)createFlutterContainer
......
...@@ -30,6 +30,5 @@ ...@@ -30,6 +30,5 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@interface FLBFlutterApplication : NSObject<FLBFlutterApplicationInterface> @interface FLBFlutterApplication : NSObject<FLBFlutterApplicationInterface>
+ (FLBFlutterApplication *)sharedApplication;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
...@@ -39,16 +39,6 @@ ...@@ -39,16 +39,6 @@
@implementation FLBFlutterApplication @implementation FLBFlutterApplication
@synthesize platform; @synthesize platform;
+ (FLBFlutterApplication *)sharedApplication
{
static FLBFlutterApplication *instance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
instance = [self new];
});
return instance;
}
- (BOOL)isRunning - (BOOL)isRunning
{ {
return _isRunning; return _isRunning;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment