Categories
Uncategorized

Redux architecture for swiftui

In the development of modern applications, managing the state efficiently and scalable is crucial. One of the most popular architectures for state management is Redux, which offers a clear and predictable way to handle the status of the application. This article explores how to implement a REDux architecture in a swiftui application using Reswift and Reswiftthunk, along with the use pattern to encapsulate business logic. But if you are like me, and you like to put hands to the code directly, you can check the repository with the implementation here (https://github.com/transmigrado/archocurheswiftui), if you still do not know Redux and you would like to explore it as an alternative To your developments on Swift using swiftui, this article will help you leave.

The motivation to implement a REDux architecture in one of the projects in which I am working, is born of the need to have more compatible architectures with the most modern work forms such as Jetpack Compose and in the case of iOS Swiftui, these two declarative technologies In order to create interfaces in mobile environments, they are very compatible with reactive architectures such as Redux, allowing enough friendly life cycles to maintain.

In the project, Firebase was used for comfort issues, what was wanted to explore was like implementing an architecture that is handled by actions to modify the states of the application. You feel free to use the project, adding your own data consumption, since architecture is fully isolated from business logic, which is encapsulo in use cases (uses)

 

What is Redux?

REDux is a predictable state management architecture initially designed for JavaScript applications, especially those built with React. The main idea behind Redux is to have a single store (storage) that contains the status of the application and can only be modified through actions. A reducer, which is a pure function, receives the action and the current state, and returns a new state.

 

What is Reswift?

Reswift is an implementation of REDux on Swift for iOS applications. Redux is a predictable architecture pattern for the management of the application status, initially popularized by JavaScript applications such as those created with React. Reswift takes this pattern to the Swift ecosystem, offering a clear and structured way to handle the state of your iOS application.

 

What is Reswiftthunk?

Reswiftthunk is a reswift extension that allows the handling of asynchronous logic and secondary actions. Thunks are functions that can dispatch other actions or execute additional logic before dispatching an action. In Reswift, THUNKS help maintain the state of the clean and predictable application while allowing asynchronous operations such as call calls, database (chore .

You can find these two bookstores in their respective repositories:

Reswift repository: (https://github.com/reswift/reswift)

Reswift-Thunk repository: (https://github.com/reswift/reswift-thunk)

 

The data flow in this architecture will see something like that, usually the UI will shoot an action, this action will be received by the reducer, which will modify the state and in turn, this state will be heard by our UI component, in addition to being able to launch Secondary actions, such as calling an API or the database, we will use a thunk, the thunk will be a kind of bridge between the REDux flow and our business logic, which will be encapsulated in a use

 

What is a reducer?

A reducer is a pure function that takes the current state of the application and an action as arguments, and returns a new state. The reducer function should not have side effects, that is, we must not use this function to call APIs, local databases or modify the UI, we only modify the properties based on an action, as shown below

In this way we can create the necessary unit tests to prove a reduction, we must simply declare a state and the action we want to prove, after the reducer is invoked with this action, the new state must meet our conditions.

What is a thunk?

A thunk is a function that is used to handle asynchronous actions or actions that do not result in immediate state changes. In other words, it allows us that a dispatched action is not only an object of simple action, but can be a function that contains additional logic, such as API calls, consultations to a local database or any other asynchronous operation, before dispatch regular action.

A thunk will be a function that does not directly return an object of action, but returns a function that receives the Dispatch as an argument. This function can execute asynchronous logic and then dispatch one or more actions based on the result of this logic.

As we describe before, we will use a thunk to execute an asynchronous effect, in this case we will call Fetchashncdata of our use to bring the posts and then dispatch an action so that the state of our application changes.

Here we can see how a thunk works communicating with the flow we describe at the beginning, we will detail each step.

PostThunks

The postthunks class acts as a container for asynchronous logic that recovers posts from a service or use case.

  • Método fetchThunk():
    This method returns a THUNK, which is a function that allows asynchronous operations to be executed before dispatching actions in the Redux flow.

    • Thunk fetchThunk:
      This Thunk receives Dispatch (which allows dispatching actions) and Getstate (which allows access to the current state) as arguments. This is where the flow of the actions is managed as well

      • Dispatch(FetchAction()): Before executing the asynchronous task, an action called fetchaction is dispatched, which probably indicates in the user interface that the application is loading (such as showing a load indicator).
      • Task {}: A task block is used to run asynchronous code within the context of the THUNK. Here is called the Fetchasyncdata () method from the Usecase, which is an asynchronous call that recovers posts data.
      • Dispatch(PostsAction(list: posts)): If the API call is successful, the recovered posts are dispatched through the postsaction action, which will update the status of the application with the posts list.

 

PostsState:

This structure defines how the state related to the posts in the application is represented.

  • list: Stores a list of posts that will be displayed in the application.
  • isLoading: Indicate whether the application is currently in the process of loading the data.
  1. postsReducer :

This reducer has the function of taking action and the current state of the application and returns a new state, updated according to the action.

  • FetchAction: When this action is dispatched, the reducer changes the Isloading value to True, indicating that the application is in the process of obtaining data.
  • PostsAction: When the posts are recovered and dispatched, this action updates the list of posts in the state (state.posts.list) and puts isloading in false, indicating that the load is over.
  1. General flow of thunk:
  • When calling Fetchthunk (), the Thunk dispatches the fetchaction action to indicate that the posts load has begun.
  • Then make an asynchronous call to recover the posts through the use.
  • If the call is successful, dispatched the postsaction action with the list of posts obtained, which the State updates.
  • If the so -called failure, it simply prints the error without affecting the State (although it could be improved with an error action).

 

In conclusion, the combination of REDux with Reswift and Reswiftthunk offers a robust and predictable architecture to handle the state in Swiftui applications. By encapsulating the business logic in uses and handling asynchronous actions through Thunks, a clear and efficient flow is achieved to manage the life cycle of the data. This approach not only allows a more organized and testable code, but also facilitates the implementation of scalable and maintainable architectures in modern mobile projects. Inviting developers to explore this architecture is an excellent opportunity to improve their skills in asynchronous state management and logic in Swiftui applications.

 

By: Jorge Acosta Tech Lead

Categories
Uncategorized

What does an iOS developer do?

IOS developers are technology professionals who specialize in creating applications for Apple's mobile operating system. Since its launch in 2007, IOS has evolved to become one of the most popular and advanced mobile operating systems in the world. Thanks to their success, iOS developers are increasingly important in the technology industry, since they create applications that meet the needs of users and help boost the growth of companie

IOS developers are responsible for designing, developing and maintaining mobile applications for iPhone, iPad, Apple Watch and other iOS devices. They use programming languages ​​such as Swift and Objective-C, as well as development tools such as XCODE, to create applications that work on iOS devices. In addition, iOS developers must follow Apple design guidelines and standards to ensure that applications are perfectly integrated with the operating system and are easy to use.
In addition to the programming, iOS developers must have skills in the user interface design (IU) and user experience (UX), to ensure that their applications are attractive and easy to use. This includes working with graphics, animations, transitions and other visual elements that help make the application more attractive to the end user.

IOS developers must also be aware of technological trends and advances in the industry, to ensure that their applications are compatible with the latest iOS devices and the latest versions of the operating system. In addition, they must be familiar with third -party tools and services that are commonly used in the development of mobile applications, such as cloud services and social networks.

And you? Do you need an iOS developer? If you are looking for a professional, Smartjob finds it for you. Contact us today.

Categories
Uncategorized

Android developer

1.662 / 5.000 Android developers are professionals who specialize in creating applications for Google's mobile operating system. Since its launch in 2008, Android has become one of the most popular mobile operating systems in the world. Android developers have played a very important role in the technology industry because they have allowed to create and adapt applications that meet the needs of users.

Android developers use programming languages ​​such as Java and Kotlin, as well as development tools such as Android Studio, to create applications that work on Android devices. In addition, Google design guidelines and design standards must follow to ensure that applications are perfectly integrated with the operating system and are easy to use.

In addition to programming, Android developers must have skills in the design of UI and UX to ensure that their applications are attractive and easy to use. They must also be aware of the trends and technological advances in the industry and be familiar with third -party tools and services that are commonly used in the development of mobile applications.

Compared to iOS developers, Android developers have to deal with a large number of devices and versions of the operating system. However, this also means that they can reach a broader audience. In general, Android developers are a vital part of the technology industry and play an important role in the development of mobile applications for Android devices.

And you? Do you need an Android developer? If you are looking for a professional, Smartjob finds it for you. Contact us today.

Categories
Uncategorized

How do workers see the attributes of the AI ​​(artificial intelligence)?

A Laborum survey in Chile revealed that most respondents (61%) believe that artificial intelligence (AI) will have a positive impact on the workplace. While 20% of respondents think that AI technology will have a negative impact and 18% believe the impact will not be significant. Of those with a positive opinion about AI, 47% highlighted the possibility of incorporating new knowledge and skills in their work to professionalize.

In Latin America, the survey was also conducted in other countries where similar figures are observed. The regional average is 78%. As for the IT market in the world, an Oracle study found that 77% of IT workers believe that AI will improve their work and allow them to focus on more important and creative tasks. In addition, 64% of respondents think the AI ​​will improve information security. In summary, although there is a concern for the replacement of workers in specific areas, most people in Chile and Latin America see a positive impact on the incorporation of AI in the workplace.

For us on Smartjob, being attentive to the novelties of the computer world is key to looking for the talents that your company needs. If you are looking for a professional, Smartjob finds it for you. Contact us today.

Categories
Uncategorized

How do workers see the attributes of the AI ​​(artificial intelligence)?

If you are here you know what outsourcing is about, but let's review concepts before Seual with the subject. Also known as subcontractor, it has become an increasingly common practice in Latin America. It is a business model in which a company hires the services of another to make dating tasks, instead of doing so with its own staff.

According to a study by Deloitte, the Outsourcing market in Latin America has had an annual growth of 6.3% in recent years, and it will continue to continue growing at a rate of 6% annually. ruled a representative of Ti services.

That said, from Smartjob we are looking for the way that each of our clients obtain the best of this 53% and thus grow their business digitally.

We are committed to making the most thorough selection process when finding the profile of IT that you need as a company, from Business Analyst to Developer Java or any other, because we understand that each role has different skills and it is not only “to hire a you "

en_US