Git Product home page Git Product logo

suiflow's Introduction

Project Description: SUIFlow Library

The purpose of this project is to create a library, SUIFlow, that aids developers in efficiently developing user interface interaction flows.

Use Case Scenario:

  1. A user selects a state from a dropdown list.
  2. Every suburb in the selected state is displayed as polygons on the map.
  3. The user picks a suburb.
  4. The user draws a rectangle on the map.
  5. The user fills out a form.
  6. The system generates a PDF map based on these steps.
  7. if user starts another flow before finish this one, system closes this flow automatically and cleanup all resources.

While this scenario can be implemented with traditional coding methods, such an approach is often time-consuming, difficult to maintain, and can lead to inconsistencies across different developers' implementations. SUIFlow addresses these challenges by providing the following features:

  • Specify user interaction logic with Flow: Developers specify the user interaction using JavaScript or TypeScript as a Flow. The code follows a synchronous style, so flow developers do not need to manage the asynchronous nature of the code. code in flow should not make side effects except Actions.

  • Make side effects in Actions: When a flow is running, it controls the user interface to display information or capture input as required, via Actions.

  • Flow Control: A flow can be cancelled, moved backward to a specified point, and restarted, allowing for flexible user interactions and easier debugging.

  • clean up resource: when a flow finishes or is cancelled, resouces it uses are released automatically. for example the event liseners are removed

By using SUIFlow, developers can create consistent and maintainable user interaction flows more efficiently.

Glossary

  • Flow: The code that implements the user interaction flow. It follows a synchronous coding style and should not make any side effects. Within the code, it invokes various actions to produce side effects.
  • Actions: Functions that produce side effects.
  • Flow Tools: a serise of utlities tools are built in to provide flow control and , essentially they are Actions.

Example

 
// A flow that uses built-in tools 'sleep', 'print', and 'restart', along with a custom Action 'add'.
const flow = runFlow(({ 
  sleep, print,  restart,
  add 
}) => {
  print('hello') 
  const result = add(1, 2) 
  sleep(1000) 
  print('world ' + result) 
  sleep(1000) 
  restart()  // Infinite loop until being cancelled
}, {
  // Implementation of 'add', can be sync or async
  add: async (a: number, b: number) => {
    return a + b 
  }
}) 

// Cancel the flow after 10 seconds from outside
setTimeout(() => {
  flow.cancel() 
}, 10 * 1000) 

suiflow's People

Contributors

shenawesome avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.