Skip to content

Commit

Permalink
fix: readme typos and descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
luisburgos committed Jun 25, 2022
1 parent 3bedfb1 commit 05a7eeb
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 10 deletions.
70 changes: 60 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ Opinionated modern event based application development framework.

### Upcoming

- Default navigator using Flutter Navigator 2.0
- Default navigator using Flutter Navigator 2.0.
- Support adding custom TypedEventHandlers and EventBuses.

## Installation

Expand All @@ -27,20 +28,69 @@ buzz:
ref: main
```

## Usage
## Initialization

### Initialization

``dart
```dart
Buzz..init(
navigator: MyAppNavigator(),
),
);
```

## Fire Events

By default the framework supports firing three base class events:
- `UiEvent`
- `Command`
- `AppEvent`

Find pre-defined [out-of-the-box supported events](./docs/EVENTS.md).

### UiEvents

The library comes with a few pre-defined `UiEvents` you can find [here](./docs/EVENTS.md).

For example, when a button/label is tapped:

```dart
ElevatedButton(
onPressed: () {
Buzz.fire(OnTapped());
},
child: Text('Tap me!'),
)
```

### Fire Events
### NavigationCommands

TODO: Add
The library comes with a few pre-defined `NavigationCommands` you can find [here](./docs/EVENTS.md).

### Listen Events
Go to a route:

TODO: Add
```dart
Buzz.fire(
NavigateToCommand.named('/my-route'),
);
```

or go back to previous route:

```dart
Buzz.fire(NavigateBackCommand());
```

## Listen Events

Use the `on` method from the `TypedEventBus` component to get a `Stream` to listen events of a specific class type.

For example, here is how we setup the listener for `NavigationCommands` as part of the features ready for you to use, this happens behind the insides:

```dart
final commandBus = EventBusHolder.of<CommandEventBus>();
final navigationCommandStream = commandBus.on<NavigationCommand>();
navigationCommandStream.listen((navigationCommand) {
NavigationCommandHandler(
navigator: _navigator,
backDefault: _navigator.backDefaultRoute,
).handle(navigationCommand);
});
```
24 changes: 24 additions & 0 deletions docs/EVENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Events

By default the framework supports firing three base class events:
- `UiEvent`: Defined as any User Interaction, it MUST be named behind user interface components.
- `Command`: Defined as requests to execute Business Logic.
- `AppEvent`: Defined as results from the execution of Business Logic code.

## UiEvents

Out-of-the-box supported UiEvents:
- `OnTapped`.
- `OnScroll` with `OnScrollDirection` enum.
- `OnSwipe` with `OnSwipeDirection` enum.
- `OnToggleChanged`.
- `OnFocusChanged`.
- `OnValueChanged`.
- `OnValueCopied`.
- `OnValuePasted`.

## Commands

### NavigationCommands

## AppEvents

0 comments on commit 05a7eeb

Please sign in to comment.