Coder Social home page Coder Social logo

isaac-israel-aquant / new-arch-sample Goto Github PK

View Code? Open in Web Editor NEW

This project forked from isaacisrael/app-news

0.0 0.0 0.0 451 KB

JavaScript 1.98% Ruby 2.24% C++ 14.19% Objective-C 4.86% Java 30.01% TypeScript 35.54% Objective-C++ 6.85% Makefile 3.11% Starlark 1.23%

new-arch-sample's Introduction

Flow

It is a self-contained app with the following parts:

  • The state, the source of truth that drives our app;
  • The screen, a declarative description of the UI based on the current state
  • The actions, the events that occur in the app based on user input, and trigger updates in the state or domain actions(business logic)

This is a small example of "one-way data flow":

  • State describes the condition of the app at a specific point in time
  • The UI is rendered based on that state
  • When something happens (such as a user clicking a button), the action trigger some business logic using async call (Saga in our case)
  • Saga will trigger a function that will execute the business logic (also will call the APIs) and update the app state
  • The UI re-renders based on the new state

sample


In our example :

  • There is a Button at WhatIsTheProblemScreen that on it onPress event will dispatch the investigationReducer.createInvestigation.
  • Saga will be trigger on this event and will be call the createInvestigation
  • The function createInvestigation will execute all business logic (calling the API)
  • In the end createInvestigation will dispatch investigationReducer.setInvestigation.
  • The State will be update in the reducer setInvestigation.
  • The UI will be re-render base on the state change

sample


Log


 INFO  "onStartNewInvestigationPress : Call the create Investigation action"
 INFO  "Create New Investigation: Start fetching"
 INFO  "Create New Investigation: Get params from the state manager"
 LOG  "Create New Investigation: Values from state manage" {
  "manufacturer": "manufacturer",
  "productType": "product type",
  "model": "model",
  "firstObservations": []
}
 INFO  "Create New Investigation: Call investigate api"
 LOG  "Create New Investigation: This is the response for investigate api" {
  "id": "test"
}
 INFO  "Create New Investigation: Call diagnose api"
 LOG  "Create New Investigation: This is the response for diagnose api" {
  "question": "Question name",
  "display": "test 1",
  "name": "test1",
  "inverted": false,
  "isFirstObservation": false,
  "isGroupAnswer": false,
  "isQuestionPresent": true
}
 INFO  "Create New Investigation: Call historic data api"
 LOG  "Create New Investigation: This is the response for historic data api" []
 INFO  "Create New Investigation: Update the app state"
 INFO  "Set Investigation State: Update investigation state with the new value" {
  "id": "test",
  "question": [
    {
      "question": "Question name",
      "display": "test 1",
      "name": "test1",
      "inverted": false,
      "isFirstObservation": false,
      "isGroupAnswer": false,
      "isQuestionPresent": true
    }
  ],
  "historicData": [],
  "firstObservations": []
}
 LOG  "Create New Investigation: Created with success"


Screen


ScreenShot


Reference


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.