<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Kobernik Yura on Medium]]></title>
        <description><![CDATA[Stories by Kobernik Yura on Medium]]></description>
        <link>https://medium.com/@kobernikyura?source=rss-eb1a34a0c0ff------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*YlBR5iAvcC99CYVY.jpg</url>
            <title>Stories by Kobernik Yura on Medium</title>
            <link>https://medium.com/@kobernikyura?source=rss-eb1a34a0c0ff------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 07:08:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kobernikyura/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Redux-models. OOP style.]]></title>
            <link>https://medium.com/@kobernikyura/redux-models-oop-style-8ffb56d0098a?source=rss-eb1a34a0c0ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ffb56d0098a</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[oop]]></category>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[redux-model]]></category>
            <dc:creator><![CDATA[Kobernik Yura]]></dc:creator>
            <pubDate>Tue, 01 Nov 2016 13:53:20 GMT</pubDate>
            <atom:updated>2016-11-01T18:42:55.213Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/443/1*QhMS255xmU7ja3YIJDFw6A.png" /></figure><p>Having used React as part of several major projects I discovered some common behavior. In common situation you have to get data from the server to a client (using action creators), do some modifications of data (can be on action creator side or on reducer side) and save this data in the application store. Using Reducers in components you can get access to application data. In the development approaches that I have used — all these steps are based on a similar structure. It consists of starting request (if need to show progress while requesting running), getting response from server, calling converters (mappers) to turn response from server into client convention, passing converted data through dispatch to reducer and catching an error if something goes wrong:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aaab8479ea8e5a430c0e39e8c1b5ce4a/href">https://medium.com/media/aaab8479ea8e5a430c0e39e8c1b5ce4a/href</a></iframe><p>Of course, this is not a unique situation and there are far more individual cases, but almost all of them are very similar to this one. And when you have got an application that consists of tens of screens and even more server endpoints for getting data it is not convenient in my opinion to have a lot of different files for developing one <strong>business model </strong>(API file for sending request, action creator, action type, reducer and mapper). Moreover, when you see that you have got a number of similar behavior cases it is better to combine them into one single model that can be used when needed instead of doing annoying monkey job.</p><p>I decided to find the way that would help me to optimise this process. Now I will tell a little bit about my concept using <strong>model</strong> in the react-redux application.</p><p>I have decided to move all the data logic into <strong>models</strong>. All the data operations and manipulations will be in one place hereinafter referred to as model! Model uses class inheritance for saving most common logic in a base class. This way enables you to use all the advantage of OOP. You can create base classes. You can write something once and then use it everywhere in sub classes.</p><p>As part of this first approach I have placed<strong> </strong>3 reducers and action creators in a <strong>base model</strong>: start requesting, get response from server and clear data if needed. In such an easy way we covered some base demand for REST API in front-end. Of course, you will have custom behavior in almost every model. This can be handle using sub models in which you can override any method or add a new one (action creators, action types, reducers or mappers).</p><p>All API requests (get, post, put, delete) also exist in the model. Every model knows where it gets data from server and how to convert request parameters from component to server and request response from server to component.</p><p>Redux stays working and you can use it as usual for some custom situations. But everything should be placed into <strong>model</strong> concept if it is possible.</p><blockquote><strong>Example of model</strong>:</blockquote><p>In this approach you have only model with all the logic (getting data from server, converting it into client view, action creators, reducers etc …) and standard redux reducer for linking your model with reducer:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6741cb3256a8565bbbec5fb295421a0b/href">https://medium.com/media/6741cb3256a8565bbbec5fb295421a0b/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fc9d33d9a94ddce08f3e781a67cb8bb6/href">https://medium.com/media/fc9d33d9a94ddce08f3e781a67cb8bb6/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0861ff79e7bd204a4365c18dc352d11c/href">https://medium.com/media/0861ff79e7bd204a4365c18dc352d11c/href</a></iframe><p>Currently I am working on a project in react and react-native and the model approach has proved to be very efficient. I have a core module that combines all the common behavior into models. And you can override all the customisation in the web and mobile part. The speed of your development work increases.</p><p>You can see the full example on <a href="https://github.com/ophite/redux-model-s"><strong><em>github</em></strong></a></p><p>If you have any questions about how it works or any recommendations, please, contact me directly at kobernik.yura@gmail.com.</p><p>Thank you for attention.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ffb56d0098a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>