-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Showing
9 changed files
with
310 additions
and
38 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
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,3 +1,4 @@ | ||
library bloc; | ||
|
||
export './src/bloc.dart'; | ||
export './src/transition.dart'; |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import 'package:meta/meta.dart'; | ||
|
||
/// Occurs when an `Event` is `dispatched` after `mapEventToState` has been called | ||
/// but before the `Bloc`'s state has been updated. | ||
/// A `Transition` consists of the currentState, the event which was dispatched, and the nextState. | ||
class Transition<E, S> { | ||
final S currentState; | ||
final E event; | ||
final S nextState; | ||
|
||
const Transition({ | ||
@required this.currentState, | ||
@required this.event, | ||
@required this.nextState, | ||
}) : assert(currentState != null), | ||
assert(event != null), | ||
assert(nextState != null); | ||
|
||
@override | ||
bool operator ==(Object other) => | ||
identical(this, other) || | ||
other is Transition<E, S> && | ||
runtimeType == other.runtimeType && | ||
currentState == other.currentState && | ||
event == other.event && | ||
nextState == other.nextState; | ||
|
||
@override | ||
int get hashCode => | ||
currentState.hashCode ^ event.hashCode ^ nextState.hashCode; | ||
|
||
@override | ||
String toString() => | ||
'Transition { currentState: ${currentState.toString()}, event: ${event.toString()}, nextState: ${nextState.toString()} }'; | ||
} |
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,13 +1,14 @@ | ||
name: bloc | ||
description: The goal of this package is to make it easy to implement the BLoC Design Pattern (Business Logic Component). | ||
version: 0.5.2 | ||
version: 0.6.0 | ||
author: felix.angelov <[email protected]> | ||
homepage: https://github.com/felangel/bloc/tree/master/packages/bloc | ||
|
||
environment: | ||
sdk: ">=2.0.0-dev.28.0 <3.0.0" | ||
|
||
dependencies: | ||
meta: ^1.1.6 | ||
rxdart: ">=0.18.1 <1.0.0" | ||
|
||
dev_dependencies: | ||
|
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.