Where does the business logic go in a React-native app?

Where does the business logic go in a React-native app?

Content Index :

Where does the business logic go in a React-native app?
Tag : android , By : Richard
Date : November 17 2020, 04:01 AM

this one helps. In react native; the render function is simply for rendering. You can have all the other logic within other functions which changes a value within the screen's state. This will refresh the screen and re-render with the new values.
For simple example:
export default class MyScreen extends Component {
  constructor(props) {
    this.state = {myValue: 0};

    this.setState({myValue: 10});

  render() {
    return (
        <TouchableOpacity onPress={this.getMyValue}>
          <Text>Get My Value</Text>
        <Text>My Value is: {this.state.myValue}</Text>

No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

How to handle business logic errors and application exceptions from business logic layer in MVC ASP.NET

Tag : asp.net-mvc , By : Reiner
Date : March 29 2020, 07:55 AM
Does that help You can decorate your Controller/Action with the [HandleErrorAttribute] to do just that.
For example:
    public ActionResult PlaceOrder(OrderDetails orderDetails)
        return View("Success");
    public ActionResult PlaceOrder(OrderDetails orderDetails)
        return View("Success");
    GlobalFilters.Filters.Add(new HandleErrorAttribute
        View = "Error"
public class HandleErrorJsonAttribute : FilterAttribute, IExceptionFilter
    public void OnException(ExceptionContext filterContext)
        filterContext.ExceptionHandled = true;
        filterContext.HttpContext.Response.StatusCode = 500;
        filterContext.HttpContext.Response.TrySkipIisCustomErrors = true;

        filterContext.Result = new JsonResult
            JsonRequestBehavior = JsonRequestBehavior.AllowGet,
            ContentType = "application/json",
            Data = new 
                Msg = "An Error Occured",
                ExceptionMsg = filterContext.Exception.ToString()

React-native Redux Should business logic be inside actions or reducers

Tag : react-native , By : protagonist
Date : March 29 2020, 07:55 AM

How to write and model a Reusable Business Logic in React Native

Tag : react-native , By : hellboy32
Date : March 29 2020, 07:55 AM
seems to work fine My advise would be to separate business logic. As you are planning to use Redux, you can create models and services into a separate package and import it wherever you need.
Models - define state, contain reducers and effects. Services - actual functions to call RestFul APIs.
import {
} from '../services/paymentService'

import {
} from '../services/profileService'

export default {
  namespace: 'myProfile',
  state: {

  reducers: {
    set: (state, {payload: details}) => {
      return ({...state, ...details})
  effects: {
    *getAge (action, { call, put, simplePut }) {
      const {payload: age} = action
      try {
        const res = yield call(upadteAge, age)
        const { status } = res
        if (status === 200) {
          const json = yield res.json()
          yield simplePut('set', json)
      } catch (error) {
export function updateAge ({age}) {
  return fetch('apiurl?age=' + age, {
    method: 'POST',
    headers: {

React native communication between view and business logic

Tag : reactjs , By : Joshua Johnson
Date : March 29 2020, 07:55 AM
Any of those help You can use below approach to solve the problem:
Return the Object { success: true, exception: false } rather than the Boolean true/false value from business logic. based the value of Object you can make the decision in your screen.
import { APICall} from './ApiClient'; 

export const businessLogic= async () => {
    try {
        let response = await APICall();
        if (response.status === 200) {
            const body = await response.json();
            return {
              success: true,
              exception: false
        } else {
            return {
              success: false,
              exception: false
    } catch (error) {
      return {
        success: false,
        exception: true
import {businessLogic} from './BusinessLogic';

onButtonPressed = async() => {
   let response = await businessLogic();

   if (response.success) {
      // handle SUCCESS case
   }else if(response.exception){
      // handle EXCEPTION case here
     // handle API ERROR case here

Is it necessary to start a new thread in the channelread method to execute the business logic even if business logic is

Tag : java , By : Paulh
Date : March 29 2020, 07:55 AM
may help you . If your business logic is performing blocking IO, than you have to do it in another thread to avoid blocking the event loop.
But if you have a non-blocking API (like when the IO operation is based on NIO), you don't have to block the thread and you don't need a new thread - you need continuation.
Related Posts Related QUESTIONS :
  • How to detect doubletap on a View?
  • how to play an encrypted file in Android
  • Android: keytool error on the command line when locating debug.keystore
  • Android paint/canvas issue; drawing smooth curves
  • Problems with starting an activity in onStart
  • Performance of map overlay in conjunction with ItemizedOverlay is very poor
  • How to change android indeterminate ProgressBar color?
  • How do I change the Mobile Country Code (MCC) in the Android Emulator?
  • Stop Progressbar manual scrolling in Android
  • Android: download large file
  • Android : uploaded .apk file to server but cant download that .apk file
  • How do I distribute Android app to beta tester without using Market
  • Android Unable to launch the Inbox from a notification
  • Android: Ringer mode changed to silent doesn't stop the phone vibrating
  • Change the side the text appears on a radio button
  • Check the memory usage anp cpu and power of an application in android
  • What is the String 'volumeName' argument of MediaStore.Audio.Playlists.Members.getContentUri referring to?
  • Playing Multiple sounds at the same time in Android
  • Android: how to change the time in emulator?
  • close the soft key pad when i click on other views in android
  • Setting the position within a spinner
  • How to play ringtone/alarm sound in Android
  • How to adjust text font size to fit textview
  • "Android 2.x" vs "Google APIs" for Android AVD Setup
  • How to center buttons on screen horizontally and vertically plus equidistant apart?
  • Discrete seekbar in Android app?
  • Gradle Build Fails - Illegal exception table range in class file com/google/wireless/android/sdk/stats/GradleBuildMemory
  • register has type Long (High Half) but expected Long (Low Half)
  • Is it good idea to use Dispatcher.Main with delay( )?
  • WebView and Advanced View is Not loading partiucalr URL
  • How to show three dots at the end of text view
  • Is it possible to run macros within Android Studio project?
  • Adding a button with default appearance but changed background color
  • What is best way to show notification at a certain time in Android?
  • Jetifier not working when library uses android component and app uses androidx component
  • How can I write the contents of an image in a filesystem
  • Retrieve a list of images from the Database and display them using a ListView?
  • java.lang.SecurityException: my location requires permission ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION
  • Timer/hourglass wont stop
  • How can I make AndroidX the default library for new Android projects?
  • Is it okay to delete buildToolsVersion android studio because of a warning in the Asyncstorage library?
  • Can I call a class that doesn't have an activity withIntent?
  • Android TextView fontFamily not working when set via TextAppearance
  • Unable to find nearby places
  • Is there any way to launch my application right away without 'Ok Google"?
  • Places api set location biased based on current location
  • Layout Preview is not displaying layout when Material Design is added
  • How do I resolve this diamond problem in Kotlin?
  • How to update the custom value in a view model object
  • How to stop refreshing/re-creating activity when updating Firebase data using setValue?
  • Manifest Permissions vs App Setttings Permissions
  • NumberFormatException in Try-Catch while converting String to Int
  • How to pass observable fields through include tag?
  • Next button on Android keyboard not submitting form
  • Does Firestore support automatic functions for updates?
  • Why app crashing because of a missing dimension (for google maps) only when I apply changes?
  • How to make a grouping, ordering and sorting: Kotlin collection
  • how to use augmented reality to change the color of a qr code once it is detected using with arcore and ml kit firebase
  • how to resolve Firebase projects adding quota problem?
  • Why it Kotlin giving me the wrong Int value when converting from a String
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com