EasyFlow


Source link: https://github.com/Beh01der/EasyFlow

EasyFlow

by DataSymphony.com.au

EasyFlow 1.3 is out (12 Dec 2013)

EasyFlow is a simple and lightweight Finite State Machine for Java

With EasyFlow you can:

  • implement complex logic but keep your code simple and clean
  • handle asynchronous calls with ease and elegance
  • avoid concurrency by using event-driven programming approach
  • avoid StackOverflow error by avoiding recursion
  • simplify design, programming and testing of complex java applications

All this in less then 30kB and no run-time overhead! Download EasyFlow 1.3

Here is a simple example illustrating how a state machine can be definded and implemented with EasyFlow

This is a State diargam fragment describing a simple ATM workflow

With EasyFlow we can define the above state machine like this

enum States implements StateEnum {

  SHOWING_WELCOME, WAITING_FOR_PIN, RETURNING_CARD, SHOWING_WELCOME, ... 
}
  enum Events implements EventEnum {

  cardPresent, pinProvided, cardExtracted, cancel, ... 
}
 ... EasyFlow<FlowContext> flow =

from(SHOWING_WELCOME).transit(

on(cardPresent).to(WAITING_FOR_PIN).transit(

 on(pinProvided).to(...).transit(

  ...

 ),

 on(cancel).to(RETURNING_CARD).transit(

  on(cardExtracted).to(SHOWING_WELCOME)

 )

)
  );

then all what's left to do is to implement our state handlers like so

whenEnter(SHOWING_WELCOME, new ContextHandler<FlowContext>() {

  @Override
  public void call(final FlowContext context) throws Exception {

...

btnOption1.setOnClickListener(new View.OnClickListener() {

 @Override

 public void onClick(View v) {

  context.trigger(cardPresent);

 
}

}
);

...
  
}
 
}
);
 ...

and start the flow

flow.start(new FlowContext());

See complete example ATM emulator - Android application

To start using EasyFlow on your project, define Maven dependency like so

<dependency>
  <groupId>au.com.datasymphony</groupId>
  <artifactId>EasyFlow</artifactId>
  <version>1.3.1</version> </dependency>

See also

EasyFlow for Node.js

License Apache 2.0

Resources

Smooth communication via bluetooth with other android devices or microcontrollers such as Arduino.

A from-scratch, re-implementation of RxAndroid with a consistent, opinionated API.

Forms, data validation... They can be annoying sometimes. This library is here to try to help you out. AndroidForms aims to be a simple, Generic form library for android. At it's core, there aren't even any dependencies! You could easily move Source, Drain, and Form into any project you'd like.

Crazy easy to use RecyclerView Adapter for Reactive Applications.

Reactive spice added to Android's network service discovery API.

Android Layout (Relative Layout, Linear Layout etc) to Image.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes