-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
committed
Jan 27, 2022
1 parent
bbaabdc
commit c9d6c51
Showing
7 changed files
with
114 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// Copyright (c) 2019, iMeshAcademy authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'package:eventify/eventify.dart'; | ||
import 'dart:async'; | ||
|
||
Future parseStores(Object config) { | ||
return new Future(() { | ||
print("Inside the future."); | ||
Map<String, Map<String, dynamic>> storeConfigs = | ||
config as Map<String, Map<String, dynamic>>; | ||
storeConfigs.forEach((str, val) { | ||
print("${str}:${val}"); | ||
val.forEach((store, details) { | ||
print("${store}:${details}"); | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
void main() { | ||
Map<String, dynamic> data = { | ||
"stores": { | ||
"store1": {"generator": 1, "config": {}}, | ||
"store2": {"generator": 2, "config": {}} | ||
}, | ||
"models": { | ||
"model1": {"generator": 1, "name": "modelel1", "linkedStore": "store1"} | ||
} | ||
}; | ||
|
||
Function parseModels = (config) {}; | ||
|
||
print(data.runtimeType); | ||
data.forEach((key, val) { | ||
switch (key) { | ||
case "stores": | ||
parseStores(val).then((res) { | ||
print("Store is parsed"); | ||
}); | ||
break; | ||
case "models": | ||
parseModels(val); | ||
break; | ||
default: | ||
} | ||
}); | ||
|
||
print("After the loop!!"); | ||
|
||
EventEmitter emitter = new EventEmitter(); | ||
emitter.on("test", null, (ev, context) { | ||
print("${ev.eventName} - ${ev.eventData}"); | ||
}); | ||
|
||
emitter.emit("test", null, "Test data"); | ||
|
||
int count = 0; | ||
|
||
ExtendedEmitter timer = new ExtendedEmitter(); | ||
timer.on("timer", null, (ev, context) { | ||
count++; | ||
print("Received ${ev.eventName} event from ${ev.sender}!"); | ||
if (count == 10) { | ||
Timer t = ev.eventData as Timer; | ||
t.cancel(); | ||
} | ||
}); | ||
|
||
timer.doSomeOperation(); | ||
} | ||
|
||
class ExtendedEmitter extends EventEmitter { | ||
void timerCallback(Timer timer) { | ||
emit("timer", this, timer); | ||
} | ||
|
||
void doSomeOperation() { | ||
Timer.periodic(Duration(seconds: 1), timerCallback); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,5 +12,6 @@ dev_dependencies: | |
lints: ^1.0.0 | ||
|
||
dependencies: | ||
eventify: ^1.0.0 | ||
ffi: ^1.1.2 | ||
switchscript: ^0.0.1 |