-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify the EventBus API: Allow any Dart object as an event (see issue
#11)
- Loading branch information
1 parent
2700e14
commit a6ab765
Showing
14 changed files
with
419 additions
and
426 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
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 |
---|---|---|
@@ -1,20 +1,24 @@ | ||
/** | ||
* This is an example of how to set up events used by the event bus. | ||
* This is an example of how to set up the [EventBus] and its events. | ||
*/ | ||
library events; | ||
|
||
import 'package:event_bus/event_bus.dart'; | ||
export 'package:event_bus/event_bus.dart'; | ||
|
||
EventBus _eventBus; | ||
|
||
/// The global [EventBus] object. | ||
EventBus get eventBus => _eventBus; | ||
EventBus eventBus = new EventBus(); | ||
|
||
/// Event A. | ||
class MyEventA { | ||
String text; | ||
|
||
MyEventA(this.text); | ||
} | ||
|
||
/// Initializes the global [EventBus] object. Should only be called once! | ||
void init(EventBus eventBus) { | ||
_eventBus = eventBus; | ||
/// Event B. | ||
class MyEventB { | ||
String text; | ||
|
||
MyEventB(this.text); | ||
} | ||
|
||
final EventType<String> textUpdateA = new EventType<String>('textUpdateA'); | ||
final EventType<String> textUpdateB = new EventType<String>('textUpdateB'); |
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 |
---|---|---|
@@ -1,46 +1,16 @@ | ||
|
||
body { | ||
background-color: #F8F8F8; | ||
font-family: 'Open Sans', sans-serif; | ||
font-size: 14px; | ||
font-weight: normal; | ||
line-height: 1.2em; | ||
margin: 15px; | ||
} | ||
|
||
h1, p { | ||
color: #333; | ||
} | ||
|
||
#example-container { | ||
width: 620px; | ||
margin-bottom: 20px; | ||
} | ||
|
||
#example-container .listener { | ||
width: 300px; | ||
margin: 5px 5px 20px 5px; | ||
padding: 10px; | ||
float: left; | ||
position: relative; | ||
border: 1px solid #ccc; | ||
background-color: #fff; | ||
-webkit-box-sizing:border-box; | ||
-khtml-box-sizing:border-box; | ||
-moz-box-sizing:border-box; | ||
box-sizing:border-box; | ||
} | ||
|
||
#example-container .listener * { | ||
margin-top: 5px; | ||
margin-top: 5px; | ||
} | ||
|
||
#example-container .listener textarea { | ||
display: block; | ||
width: 270px; | ||
height: 100px; | ||
} | ||
|
||
#example-container .event { | ||
display: block; | ||
width: 270px; | ||
height: 100px; | ||
} |
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
Oops, something went wrong.