nop 0.0.3 copy "nop: ^0.0.3" to clipboard
nop: ^0.0.3 copied to clipboard

outdated

Isolate 通信

提供一种Isolate编程的解决方案。

示例 #


part 'isolate_event.g.dart';

@NopServerEvent()
@NopServerEventItem(serverName: 'isolate') // 其他未命名的默认在 'isolate' Isolate 中
abstract class IsolateEvent implements FirstEvent, SecondEvent, ThirdEvent {}

/// 通常会创建一个新的 名为'first_isolate'的 Isolate
@NopServerEventItem(serverName: 'first_isolate')
abstract class FirstEvent {
  FutureOr<bool?> workStatus();
  FutureOr<String?> getBookName(int id);
}

/// 未命名的类会在默认的 Isolate 中
abstract class SecondEvent implements OtherEvents {
  Stream<String?> getStream();
}

/// third_isolate 可以与 'first_isolate' 通信
@NopServerEventItem(
    serverName: 'third_isolate', connectToServer: ['first_isolate'])
abstract class ThirdEvent {
  // function
}

abstract class OtherEvents {
  void doOtherWrok();
}

运行 dart run build_runner build之后,生成的代码会在 isolate_event.g.dart 文件中

1
likes
0
points
0
downloads

Publisher

unverified uploader

Weekly Downloads

Isolate 通信

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

characters, collection, equatable, meta, nop_annotations

More

Packages that depend on nop