Line data Source code
1 : /// BloC class that the generator will be looking for. 2 : class RxBloc { 3 : /// By convention the `Events` class should be composed of ${blocName}Events. 4 : /// For instance of the BloC class name is `CounterBloc` the events abstract 5 : /// class should be named `abstract class CounterEvents`. 6 : /// In case you want to name it differently just provide 7 : /// the expected name in [eventsClassName]. 8 : /// 9 : /// By convention the `States` class should be composed of ${blocName}States. 10 : /// For instance of the BloC class name is `CounterBloc` the events abstract 11 : /// class should be named `CounterStates`. In case you want to name it 12 : /// differently just provide the expected name in [statesClassName]. 13 3 : const RxBloc({ 14 : this.eventsClassName = 'Events', 15 : this.statesClassName = 'States', 16 : }); 17 : 18 : /// Events class that the generator will be looking for. 19 : /// 20 : /// In case you need to name the BloC's event class with a name, which does 21 : /// not stick to the convention you can override it from here 22 : final String eventsClassName; 23 : 24 : /// States class that the generator will be looking for. 25 : /// 26 : /// In case you need to name the BloC's states class with a name, which does 27 : /// not stick to the convention you can override it from here 28 : final String statesClassName; 29 : } 30 : 31 : /// There might be some situations where you would need to define custom state, 32 : /// where all generated boilerplate it would be redundant. 33 : /// For that case just annotate the property of the states class 34 : /// with @RxBlocIgnoreState() and the generator won't generate any boilerplate 35 : /// code for it. 36 : /// A good example of this is errors or loading states as shown 37 : /// [here](https://github.com/Prime-Holding/RxBloc#usage). 38 : class RxBlocIgnoreState { 39 : /// das das 40 3 : const RxBlocIgnoreState(); 41 : } 42 : 43 : /// When working with events, most of the time, they are used to publish changes 44 : /// to the bloc that do not require any initial state. 45 : /// However, there may be some times when you are required to set the state 46 : /// to a custom value or to explicitly annotate the event. 47 : /// All this can be done with the @RxBlocEvent() annotation. 48 : /// 49 : /// For more information look 50 : /// [here](https://github.com/Prime-Holding/RxBlocGenerator#rxblocevent) 51 : class RxBlocEvent { 52 : /// @RxBlocEvent annotation has two parameters: the type of the event and 53 : /// the seed value. The type specifies what kind of event will be generated 54 : /// and it can either be a publish event (the default one) 55 : /// or a behaviour event. The seed value, on the other hand, 56 : /// is a value that is valid if used with a behaviour event and represents 57 : /// the initial seed. If the annotation is omitted, the event is treated as 58 : /// a publish event. 59 0 : const RxBlocEvent({ 60 : this.type = RxBlocEventType.publish, 61 : this.seed, 62 : }); 63 : 64 : /// Type of the event, that can be either [RxBlocEventType.behaviour] or 65 : /// [RxBlocEventType.publish] 66 : final RxBlocEventType type; 67 : 68 : /// The initial value of the event 69 : final dynamic seed; 70 : } 71 : 72 : /// Subject type of the event. It could be either [RxBlocEventType.behaviour] 73 : /// or [RxBlocEventType.publish] 74 : /// 75 : /// In case the type of choice is [RxBlocEventType.behaviour] there could be 76 : /// set a initial (seed) value. 77 3 : enum RxBlocEventType { 78 : /// The type of the subject that generator will generate. 79 : behaviour, 80 : 81 : /// The type of the subject that generator will generate. 82 : publish, 83 : }