FLTThreadSafeEventChannel.h 938 Bytes
Newer Older
jzhang's avatar
jzhang committed
1 2 3 4 5 6 7 8
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <Flutter/Flutter.h>

NS_ASSUME_NONNULL_BEGIN

朱国瑞's avatar
朱国瑞 committed
9 10
/// A thread safe wrapper for FlutterEventChannel that can be called from any thread, by dispatching
/// its underlying engine calls to the main thread.
jzhang's avatar
jzhang committed
11 12
@interface FLTThreadSafeEventChannel : NSObject

朱国瑞's avatar
朱国瑞 committed
13 14
/// Creates a FLTThreadSafeEventChannel by wrapping a FlutterEventChannel object.
/// @param channel The FlutterEventChannel object to be wrapped.
jzhang's avatar
jzhang committed
15 16
- (instancetype)initWithEventChannel:(FlutterEventChannel *)channel;

朱国瑞's avatar
朱国瑞 committed
17 18
/// Registers a handler on the main thread for stream setup requests from the Flutter side.
/// The completion block runs on the main thread.
jzhang's avatar
jzhang committed
19 20 21 22 23 24
- (void)setStreamHandler:(nullable NSObject<FlutterStreamHandler> *)handler
              completion:(void (^)(void))completion;

@end

NS_ASSUME_NONNULL_END