This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
final okNoError = {'ok': true, 'error':null}; | |
final errorNotOk = {'ok': false, 'error':true}; | |
final invalidMap = {'alien': 'invasion'}; | |
if (okNoError['ok'] ?? false) { | |
print('ok, no error'); | |
} | |
if (errorNotOk['ok'] ?? false) { | |
print('will not print.'); | |
} else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:dorker/dorker.dart'; | |
import 'package:application/service.dart'; | |
main() { | |
Service(DorkerBoss()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dorker _service; | |
if (const String.fromEnvironment('USE_WORKER') == 'true') { | |
print('Asked to use worker'); | |
_service = DorkerWorker(Worker('worker/service.dart.js')); | |
} else { | |
print('Not using worker'); | |
_service = Dorker(); | |
Service(Dorker.CrossLink(_service)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@JS() | |
library docker_web; | |
import 'dart:html' show Worker; | |
import 'package:js/js.dart'; | |
import 'dorker_base.dart'; | |
@anonymous |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Dorker<T> { | |
@protected | |
final incoming = StreamController<T>(); | |
@protected | |
final outgoing = StreamController<T>(); | |
Stream<T> get onMessage => incoming.stream; | |
Sink<T> get postMessage => outgoing.sink; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@JS() | |
library dogs; | |
import 'package:js/js.dart'; | |
@JS() | |
@anonymous | |
class Dog { | |
external String get name; | |
external int get age; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:js/js.dart'; | |
import 'package:excel_worker/dog.dart'; | |
@anonymous | |
@JS() | |
abstract class MessageEvent { | |
external dynamic get data; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
import 'dart:html'; | |
import 'package:excel_worker/dog.dart'; | |
void main() { | |
var w = Worker('worker/dog_raiser.dart.js'); | |
// Listen to Worker's postMessage(). | |
// dart.html convert the callback to a Stream. |