<?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 HTD on Medium]]></title>
        <description><![CDATA[Stories by HTD on Medium]]></description>
        <link>https://medium.com/@HTD?source=rss-ed43dcb88a16------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Q39YF9_E8BSa39A6sbAtTw.png</url>
            <title>Stories by HTD on Medium</title>
            <link>https://medium.com/@HTD?source=rss-ed43dcb88a16------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 16:08:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@HTD/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[Testing redux action sequences]]></title>
            <link>https://medium.com/@HTD/testing-redux-action-sequences-c0abcf406ed2?source=rss-ed43dcb88a16------2</link>
            <guid isPermaLink="false">https://medium.com/p/c0abcf406ed2</guid>
            <category><![CDATA[learn-react-js]]></category>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[react-js-tutorials]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[HTD]]></dc:creator>
            <pubDate>Sat, 09 Dec 2017 00:00:00 GMT</pubDate>
            <atom:updated>2017-12-11T21:06:48.689Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BpaqVMW2RjQAg9cFHcX1pw.png" /></figure><p>Testing the features implemented with redux (actions, reducers) is conceptually quite easy. This is due to redux’ simplicity. Actions are plain objects, and reducers are pure functions that accept everything they need as arguments. There’s no need to mock the external world.</p><p>On the other hand, a lot of small unit tests are required to fully test an impact of every action and state transition. That could deter from writing them in the first place.</p><p>I think that we developers should harness redux’ simplicity to write better tests. I want to share two approaches I use for more complete redux coverage, especially when dealing with action sequences.</p><h3>Setup</h3><p>Let’s have an obligatory counter reducer as an example. The possible actions should be incrementing and decrementing the counter.</p><pre><em>// Constants</em> <br><strong>const</strong> INCREMENT <strong>=</strong> &quot;counter/INCREMENT&quot;;<br><strong>const</strong> DECREMENT <strong>=</strong> &quot;counter/DECREMENT&quot;;</pre><pre><em>// Action creators<br></em><strong>const</strong> increment <strong>=</strong> () <strong>=&gt;</strong> ({ type: INCREMENT });<br><strong>const</strong> decrement <strong>=</strong> () <strong>=&gt;</strong> ({ type: DECREMENT });  </pre><pre><em>// Reducer<br></em><strong>const</strong> initialState <strong>=</strong> { count: 0 };<br><strong>function</strong> counter(state <strong>=</strong> initialState, action) {<br>  <strong>switch</strong>(action.type) { <br>    <strong>case</strong> INCREMENT: <br>      <strong>return</strong> { ...state, count: state.count <strong>+</strong> 1 }; <br>    <strong>case</strong> DECREMENT: <br>      <strong>return</strong> { ...state, count: state.count <strong>-</strong> 1 }; <br>    <strong>default</strong>: <br>      <strong>return</strong> state; <br>  } <br>}</pre><p>The most basic tests of this reducer would have a simple structure: given an initial state and an action, the resulting state should be equal to the expected state:</p><pre><strong>const</strong> initialState <strong>=</strong> { count: 3 };<br><strong>const</strong> action <strong>=</strong> increment();<br><strong>const</strong> expectedState <strong>=</strong> { count: 4 }; </pre><pre>expect(counter(initialState, action)).toEqual(expectedState);</pre><p>Tests of this kind are very useful, but they quickly become repetitive and too numerous, because we only test one state / action at a time.</p><p>So, here are a few more ways that we can test a sequence of actions.</p><h3>Reducing a sequence of actions to single state</h3><p>One kind of a useful reducer test is the one that asserts what the state is after a sequence of actions has been processed (for example, incrementing twice and decrementing once).</p><p>Here’s what it may look like: it defines an initial state and invokes the reducer with intermediate states and every action in turn. At the end, it assert that the state is correct.</p><pre><strong>const</strong> initialState <strong>=</strong> { count: 0 };<br><strong>const</strong> state1 <strong>=</strong> counter(initialState, increment());<br><strong>const</strong> state2 <strong>=</strong> counter(state1, increment());<br><strong>const</strong> state3 <strong>=</strong> counter(state2, decrement());</pre><pre>expect(state3).toEqual({ count: 1 });</pre><p>Notice the explicit variables for the intermediate states. This approach gets very tedious when testing long sequences of actions.</p><p>Luckily, we can rewrite that test using the Array.prototype.reduce function. This function iterates over an array, passing an accumulator variable (the state) and array item (an action) to another function. This function would be our counter reducer. The reducer naming in redux is no coincidence, as it’s directly inspired by Array.prototype.reduce!</p><pre><strong>const</strong> initialState <strong>=</strong> { count: 0 };<br><strong>const</strong> actions <strong>=</strong> [increment(), increment(), decrement()];<br><strong>const</strong> expectedState <strong>=</strong> { count: 1 };</pre><pre>expect(actions.reduce(counter, initialState)).toEqual(expectedState);</pre><p>The intermediate variables are gone and the test looks much cleaner, as well as is more extendable for longer action sequences.</p><p>Bonus point 1: if the Array.prototype.reduce version is not readable enough, I recommend creating a small helper function, e.g. reduceState.</p><pre><em>// testHelpers.js<br></em><strong>function</strong> reduceState(reducer, initialState, actions) { <br>  <strong>return</strong> actions.reduce(reducer, initialState); <br>}<br> <br><em>// counter.test.js<br></em>expect(reduceState(counter, initialState, actions)).toEqual(expectedState);</pre><p>If you’re using the excellent functional utility library <a href="http://ramdajs.com/">Ramda</a>, its <a href="http://ramdajs.com/docs/#reduce">reduce</a> function does exactly that as well:</p><pre><strong>import</strong> R from &quot;ramda&quot;;</pre><pre><strong>const</strong> reduceState <strong>=</strong> R.reduce;</pre><p>Bonus point 2: so far the examples haven’t imported the redux library code at all. But, we can also rewrite the previous test by instantiating the store with our small reducer. This is a bit more verbose, but could be useful as well.</p><pre><strong>import</strong> { createStore } from &quot;redux&quot;; </pre><pre><strong>const</strong> initialState <strong>=</strong> { count: 0 };<br><strong>const</strong> store <strong>=</strong> createStore(counter, initialState);<br>store.dispatch(increment());<br>store.dispatch(increment());<br>store.dispatch(decrement());<br>expect(store.getState()).toEqual({ count: 1 });</pre><h3>Accumulating state while reducing</h3><p>Another type of test is also concerned with a sequence of actions, but it asserts correct state at every step, not only at the end. This way we can have more granular expectations about how the state changes.</p><pre><strong>const</strong> initialState <strong>=</strong> { count: 0 };<br><strong>const</strong> state1 <strong>=</strong> counter(initialState, increment());<br>expect(state1).toEqual({ count: 1 });<br><strong>const</strong> state2 <strong>=</strong> counter(state1, increment());<br>expect(state2).toEqual({ count: 2 });<br><strong>const</strong> state3 <strong>=</strong> counter(state2, decrement());<br>expect(state3).toEqual({ count: 1 });</pre><p>There’s a way of making this test more succinct; however, it requires a small helper, not present in the core language like Array.prototype.reduce. This helper will accept a reducer, initial state and array of actions, and return an array of states, beginning from the initial, through intemediate, and ending in the final state.</p><p>Let’s call it accumulateState:</p><pre><strong>function</strong> accumulateState(reducer, initialState, actions) { <br>  <strong>const</strong> result <strong>=</strong> [initialState]; <br>  actions.forEach((action) <strong>=&gt;</strong> { <br>    <strong>const</strong> currentState <strong>=</strong> result[result.length <strong>-</strong> 1]; <br>    <strong>const</strong> nextState <strong>=</strong> reducer(currentState, action); <br>    result.push(nextState); <br>  }); <br>  <strong>return</strong> result;<br>}</pre><p>Using the helper method, the test looks like this:</p><pre><strong>const</strong> initialState <strong>=</strong> { count: 0 }; <br><strong>const</strong> actions <strong>=</strong> [increment(), increment(), decrement()]; <br><strong>const</strong> expectedStates <strong>=</strong> [{ count: 0 }, { count: 1 }, { count: 2 }, { count: 1 }]; </pre><pre>expect(accumulateState(counter, initialState, actions)).toEqual(expectedStates);</pre><p>Bonus point 1: this approach works great with <a href="https://facebook.github.io/jest">jest</a> and <a href="https://facebook.github.io/jest/docs/en/snapshot-testing.html">snapshot testing</a>. The expected states array can be conveniently captured as a snapshot:</p><pre><strong>const</strong> initialState <strong>=</strong> { count: 0 }; <br><strong>const</strong> actions <strong>=</strong> [increment(), increment(), decrement()]; <br>expect(accumulateState(counter, initialState, actions)).toMatchSnapshot();</pre><p>Bonus point 2: if you’re using <a href="http://ramdajs.com/">Ramda</a>, there’s no need to implement a helper — Ramda already has a function that has this exact behaviour. It’s called <a href="http://ramdajs.com/docs/#scan">scan</a>.</p><pre><strong>import</strong> R from &quot;ramda&quot;; </pre><pre><strong>const</strong> accumulateState <strong>=</strong> R.scan;</pre><p>Bonus point 3: analogously, the store version would look like this:</p><pre><strong>import</strong> { createStore } from &quot;redux&quot;; </pre><pre><strong>const</strong> initialState <strong>=</strong> { count: 0 }; <br><strong>const</strong> store <strong>=</strong> createStore(counter, initialState); <br>store.dispatch(increment()); <br>expect(store.getState()).toEqual({ count: 1 }); <br>store.dispatch(increment()); <br>expect(store.getState()).toEqual({ count: 2 }); <br>store.dispatch(decrement()); expect(store.getState()).toEqual({ count: 1 });</pre><h3>Summary</h3><p>In this article, I introduced two little utility functions for testing redux reducers: reduceState and accumulateState. These fuctions should aid in testing long sequences of actions. For me, these tests also feel more concrete: we’re testing how the state changes during the entire interaction, not only one transition at a time.</p><p>A word of clarification: in my examples, I used the action creators (increment, decrement) instead of plain object actions. This way, the reducer and action creators are tested “together” in a single test. I think that’s fine; in fact, it gives me more confidence that the two will work together correctly in a real application. I tend not to write unit tests for action creators alone (unless they contain some tricky logic, but that’s very rare).</p><p>I hope these techniques are useful. What other approaches do you use in your tests? Let me know in the comments!</p><p><em>Originally published at </em><a href="http://pewniak747.info/2017/12/09/testing-redux-action-sequences/"><em>pewniak747.info</em></a><em> on December 9, 2017.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c0abcf406ed2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tracking asynchronous operations with redux]]></title>
            <link>https://medium.com/@HTD/tracking-asynchronous-operations-with-redux-ac741d21509c?source=rss-ed43dcb88a16------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac741d21509c</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[react-js-tutorials]]></category>
            <category><![CDATA[learn-react-js]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[HTD]]></dc:creator>
            <pubDate>Sat, 09 Sep 2017 00:00:00 GMT</pubDate>
            <atom:updated>2017-12-12T09:33:14.019Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BpaqVMW2RjQAg9cFHcX1pw.png" /></figure><p>A frequent complaint against <a href="https://github.com/reactjs/redux">redux</a> is the amount of code needed to achieve seemingly simple things. Which gets worse when those simple things are also common, leading to lots and lots of similar code. This is often dubbed <em>boilerplate</em>, and posed to be obviously bad (after all, Don’t Repeat Yourself is the law, right?).</p><p>Not necessarily so (I think DRY is a very overrated principle, but that’s a thought for another post). One thing the boilerplate is useful for is identifying patterns. If there’s a lot of identical code in multiple places in the codebase (not two, not three, ideally four or more), that’s a strong indicator we’re missing an <em>abstraction</em>.</p><p>There’s a particular use case for abstractions in redux apps — happens very often, feels repetitive, and could use a better solution.</p><p>That use case is: <strong>performing AJAX requests</strong>.</p><p><em>(note: if all your app really does is simple data fetching — </em><a href="https://medium.com/@dan_abramov/you-might-not-need-redux-be46360cf367"><em>You might not need redux</em></a><em>)</em></p><h3>Requirements</h3><p>Let’s identify what are the requirements of a feature that fetches a list of widgets.</p><p>The redux state needs to know:</p><ul><li>Whether the widgets are loading or not</li><li>Whether the widgets have been loaded successfully or not</li><li>Error details if the request has failed</li><li>The widget data itself</li></ul><p>A common way to implement this feature with redux (using best practices for action creators etc) involves writing:</p><ul><li>3 action types (WIDGETS_REQUEST, WIDGETS_SUCCESS, WIDGETS_FAILURE)</li><li>3 action creators (widgetsRequest, widgetsSuccess, widgetsFailure)</li><li>A reducer that sets the appropriate fields in the state</li><li>A <a href="https://github.com/gaearon/redux-thunk">thunk</a> dispatching the actions and performing the ajax request itself</li></ul><p>It might look like this:</p><pre><strong>const</strong> WIDGETS_REQUEST <strong>=</strong> &#39;WIDGETS_REQUEST&#39;; <br><strong>const</strong> WIDGETS_SUCCESS <strong>=</strong> &#39;WIDGETS_SUCCESS&#39;; <br><strong>const</strong> WIDGETS_FAILURE <strong>=</strong> &#39;WIDGETS_FAILURE&#39;;  </pre><pre><strong>function</strong> widgetsRequest() {   <br>  <strong>return</strong> {     <br>    type: WIDGETS_REQUEST<br>   };<br>}  </pre><pre><strong>function</strong> widgetsSuccess(widgets) {<br>  <strong>return</strong> {<br>    type: WIDGETS_SUCCESS,<br>    payload: { widgets }<br>  };<br>}</pre><pre><strong>function</strong> widgetsFailure(error) { <br>  <strong>return</strong> { <br>    type: WIDGETS_FAILURE, <br>    payload: { error } <br>  }; <br>}  </pre><pre><strong>const</strong> initialState <strong>=</strong> { <br>  widgets: [], <br>  isLoading: <strong>false</strong>, <br>  isLoaded: <strong>false</strong>, <br>  error: <strong>null</strong>, <br>}; <br> <br><strong>function</strong> reducer(state <strong>=</strong> initialState, action) { <br>  <strong>switch</strong> (action.type) { <br>    <strong>case</strong> WIDGETS_REQUEST: <br>      <strong>return</strong> { <br>        ...initialState, <br>        isLoading: <strong>true</strong>, <br>      } <br>    <strong>case</strong> WIDGETS_SUCCESS: <br>      <strong>return</strong> { <br>        ...initialState, <br>        isLoaded: <strong>true</strong>, <br>        widgets: action.payload.widgets, <br>      } <br>    <strong>case</strong> WIDGETS_FAILURE: <br>      <strong>return</strong> { <br>        ...initialState, <br>        error: action.payload.error, <br>      } <br>    <strong>default</strong>: <br>      <strong>return</strong> state; <br>  } <br>} </pre><pre><strong>function</strong> fetchWidgetsThunk() { <br>  <strong>return</strong> <strong>function</strong>(dispatch) { <br>    dispatch(widgetsRequest()); <br>    fetch(&#39;/widgets.json&#39;) <br>      .then(response <strong>=&gt;</strong> response.json()) <br>      .then( <br>        (response) <strong>=&gt;</strong> dispatch(widgetsSuccess(response.widgets)), <br>        (error) <strong>=&gt;</strong> dispatch(widgetsFailure(error.message)), <br>      ); <br>  } <br>}</pre><p>For the sake of simplicity, the example assumes we’re not storing our widgets in a normalized state shape (<a href="http://redux.js.org/docs/recipes/reducers/NormalizingStateShape.html">which is recommended</a>), and instead just keep them in a list.</p><p>Even so, it’s quite a lot of code… If we’re not using the <a href="https://github.com/erikras/ducks-modular-redux">ducks pattern</a>, it’s also spread across multiple files / directories. And don’t forget the tests for it!</p><p>The biggest overhead is in implementing the reducer that tracks the request state (isLoading, isLoaded, error fields). Let’s see if we can find an abstraction here.</p><h3>Operations</h3><p>We can think of fetching the widgets as an asynchronous operation. There are three possible actions (start, success, failure) that might change its state. The state changes are defined as follows:</p><ul><li>start action makes the operation pending</li><li>success action makes the operation finished (not pending) and successful</li><li>failure action makes the operation finished and not successful — with optional error details</li></ul><p>The reducer and actions behave in the same way for every operation.</p><p>Now that the functionality is defined and isolated, we can abstract it away. Imagine a createOperation function that accepts a string (unique operation name) and returns an object with action types, action creators and a reducer, already wired up to work together:</p><pre><strong>const</strong> operation <strong>=</strong> createOperation(&#39;NAME&#39;);</pre><pre><strong>const</strong> { START, SUCCESS, FAILURE } <strong>=</strong> operation.actionTypes;<br><strong>const</strong> { start, success, failure } <strong>=</strong> operation.actionCreators;<br><strong>const</strong> { reducer, initialState } <strong>=</strong> operation;</pre><pre><em>/*<br>initialState = {<br>  pending: false,<br>  success: false,<br>  failure: false,<br>  errors: null<br>}<br>*/</em></pre><p>In this state shape, isFetching and isFetched are renamed to more fitting pending and success boolean fields. Also, the failure boolean is separate from optional errors details.</p><p>When the actions start, success and failure are dispatched to the store, the generated reducer causes a state update (setting the appropriate boolean fields and error details). We also export initialState (useful for tests) and action types (so other reducers can react to the actions, for example by saving data somewhere else in the state).</p><pre><strong>const</strong> pendingState <strong>=</strong> reducer(initialState, start());<br><em>// { pending: true, success: false, failure: false, errors: null }<br></em><strong>const</strong> successState <strong>=</strong> reducer(pendingState, success({ payloadExample: [] }));<br><em>// { pending: false, success: true, failure: false, errors: null }<br></em><strong>const</strong> failureState <strong>=</strong> reducer(pendingState, failure(&#39;An error&#39;));<br><em>// { pending: false, success: false, failure: true, errors: &#39;An error&#39; }</em></pre><p>With the createOperation function, the widgets feature now looks like this:</p><pre><strong>import</strong> { combineReducers } from &#39;redux&#39;;</pre><pre><strong>const</strong> fetchOperation <strong>=</strong> createOperation(&#39;FETCH_WIDGETS&#39;);</pre><pre><strong>function</strong> widgetsReducer(state <strong>=</strong> [], action) {<br>  <strong>switch</strong> (action.type) {<br>    <strong>case</strong> fetchOperation.actionTypes.SUCCESS:<br>      <strong>return</strong> action.payload;<br>    <strong>default</strong>:<br>      <strong>return</strong> state;<br>  }<br>}</pre><pre><strong>const</strong> reducer <strong>=</strong> combineReducers({<br>  widgets: widgetsReducer,<br>  status: fetchOperation.reducer<br>});</pre><pre><strong>function</strong> fetchWidgetsThunk() {<br>  <strong>return</strong> <strong>function</strong>(dispatch) {<br>    <strong>const</strong> { start, success, failure } <strong>=</strong> fetchOperation.actionCreators;<br>    dispatch(start());<br>    fetch(&#39;/widgets.json&#39;)<br>      .then(response <strong>=&gt;</strong> response.json())<br>      .then(<br>        (response) <strong>=&gt;</strong> dispatch(success(response.widgets)),<br>        (error) <strong>=&gt;</strong> dispatch(failure(error.message))<br>      );<br>  }<br>}</pre><p>This is much shorter! The mundane details of tracking the pending / successful / error states are abstracted away by the fetchOperation, and stored in a separate slice of state (in this case, status).</p><h3>Summary</h3><p>There are a <a href="https://github.com/gaearon/redux-thunk">multitude</a> <a href="https://github.com/redux-saga/redux-saga">of</a> <a href="https://www.npmjs.com/package/redux-api-middleware">existing</a> <a href="https://github.com/acdlite/redux-promise">ways</a> to handle AJAX requests with redux. However, they still require implementing the same reducer logic over and over again.</p><p>Using the operation abstraction has following benefits:</p><ul><li>Reduces the amount of redux code / test code written for tracking the request status. This decreases the possibility of bugs.</li><li>Decouples data state (widget attributes) from meta-data state (are widgets loading?).</li><li>Can be used with <a href="https://github.com/gaearon/redux-thunk">thunks</a>, <a href="https://github.com/redux-saga/redux-saga">sagas</a>, <a href="https://www.npmjs.com/package/redux-api-middleware">custom middlewares</a>, or any other method for handling async effects. Simply use the generated action creators!</li><li>Does not depend on anything other than the existing redux abstractions.</li><li>By exporting action types, other reducers can react to single operation state changes as well.</li><li>Can be used to track any kind of asynchronous operation, not limited to fetching and updating data via AJAX.</li></ul><p>To me, this solution shows the beauty of redux: it is simple and powerful. Because redux is so unopinionated, and uses plain objects and functions (no magic), it can sometimes feel verbose. But developers are able to create and compose elegant abstractions on top of it.</p><p>Speaking of which, implementing the createOperation function is left as an excercise to the reader. You can treat it as a programming koan to sharpen your skills. If you’re interested, my implementation is available below: See the code</p><pre><strong>function</strong> createOperation(name) {<br>  <strong>const</strong> START <strong>=</strong> `${name}/START`;<br>  <strong>const</strong> SUCCESS <strong>=</strong> `${name}/SUCCESS`;<br>  <strong>const</strong> FAILURE <strong>=</strong> `${name}/FAILURE`;</pre><pre><strong>  const</strong> start <strong>=</strong> (payload) <strong>=&gt;</strong> ({ type: START, payload });<br>  <strong>const</strong> success <strong>=</strong> (payload) <strong>=&gt;</strong> ({ type: SUCCESS, payload });<br>  <strong>const</strong> failure <strong>=</strong> (payload) <strong>=&gt;</strong> ({ type: FAILURE, payload });</pre><pre><strong>  const</strong> initialState <strong>=</strong> {<br>    pending: <strong>false</strong>,<br>    success: <strong>false</strong>,<br>    failure: <strong>false</strong>,<br>    errors: <strong>null<br>  </strong>};</pre><pre><strong>  const</strong> reducer <strong>=</strong> (state <strong>=</strong> initialState, action) <strong>=&gt;</strong> {<br>    <strong>switch</strong>(action.type) {<br>      <strong>case</strong> START:<br>        <strong>return</strong> { ...initialState, pending: <strong>true</strong> };<br>      <strong>case</strong> SUCCESS:<br>        <strong>return</strong> { ...initialState, success: <strong>true</strong> };<br>      <strong>case</strong> FAILURE:<br>        <strong>return</strong> { ...initialState, failure: <strong>true</strong>, errors: action.payload };<br>      <strong>default</strong>:<br>        <strong>return</strong> state;<br>    }<br>  };</pre><pre><strong>  const</strong> actionCreators <strong>=</strong> { start, success, failure };<br>  <strong>const</strong> actionTypes <strong>=</strong> { START, SUCCESS, FAILURE };</pre><pre><strong>  return</strong> { actionCreators, actionTypes, initialState, reducer };<br>}</pre><p><em>Originally published by Tomasz Pewiński at </em><a href="http://pewniak747.info/2017/09/09/tracking-asynchronous-operations-with-redux/"><em>pewniak747.info</em></a><em> on September 9, 2017.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac741d21509c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Does Technology Make It Better?]]></title>
            <link>https://medium.com/@HTD/does-technology-make-it-better-fe548c15a4dd?source=rss-ed43dcb88a16------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe548c15a4dd</guid>
            <category><![CDATA[healthcare-it]]></category>
            <category><![CDATA[healthtech]]></category>
            <category><![CDATA[digital-health]]></category>
            <category><![CDATA[healthcare-innovations]]></category>
            <dc:creator><![CDATA[HTD]]></dc:creator>
            <pubDate>Thu, 17 Aug 2017 00:00:00 GMT</pubDate>
            <atom:updated>2017-12-11T21:00:20.968Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6WTl8sxe-1ThjLvJ.png" /></figure><p>Art by our designer, TianRan. © HT Developers</p><p><em>Does technology actually make it better?</em></p><p>This simple question is the first I try to answer when approached about developing a digital health product. It’s one that is asked surprisingly infrequently when launching digital health products, yet essential for delivery of a winning product-market fit.</p><h3>Digital is the New Black</h3><p>Many physicians, healthcare consultants, and stakeholders are pursuing digital medicine or digital services. It seems as though the temptation goes something like this: “I do this kind of business and everyone is going digital so now it’s time for me to do that too.” The reality is that yes, you absolutely need to be thinking about how to leverage digital technologies in your work or business, but just like all of your other mission critical activities, you need to do so in a way that improves your service or offering.</p><h3>Looking Outward, Looking In</h3><p>The media industry’s move to digital can give us some ideas of how to parse what might end up a winner or loser in digital health. As internet media consumption exploded over the last decade we saw many publications move to offer their content online. So called “digital strategy” in many cases turned out to be a lack of digital strategy. One gem was the <a href="http://www.niemanlab.org/2014/05/the-leaked-new-york-times-innovation-report-is-one-of-the-key-documents-of-this-media-age/">2014 leaked strategy innovation report from the New York Times</a>. The report notes many failings of the Times’ initial forays into digital. Among them identified are a failure to customize content for readers, a lack of structuring data allowing it to be packaged into dynamic automated content, not updating content promotion strategy for digital, failures of payment models, and confusion about roles of existing employees in the digital realm. While these are interesting anecdotes, an underlaying fundamental cause is apparent — taking the same news stories as were printed in paper and just putting them online actually made the journalism worse. The product being consumed — the experience of reading the news just wasn’t as good digitally as it was with a paper. Of course there are advantages to a digital newspaper — cost of distribution chief among them. Perhaps the decision is even rational, but operational efficiencies do not necessarily equate to product or service improvements.</p><p>The unifying theme of all the report’s suggestions is that the original web foray failed to embrace the fundamental nature of the web (interactivity, dynamic content, revisions, commenting, locational awareness) to deliver a more enjoyable and informative experience than could be achieved with paper. It’s not that digital is better than paper, it’s just that if you find your desired audience is digital (or for purposes of scale or otherwise your desired medium is digital) then you must proactively shape your product to be a digital native rather than a digital transplant.</p><h3>A Digital Surface Is Not Enough</h3><p>No organizational activity is immune to the transition. Just like the startups competing against them, an offering must be re-invented to succeed in the new medium. Put simply, delivery via a new medium means creation of a new product to be delivered.</p><h3>What Not To Do</h3><p>At a meet-up some time ago, a psychiatrist explained to me that she was interested in delivering her services via telemedicine and was looking at investing in a telemedicine solution to move her practice to the digital age. As an independent practice which had been around for some time this physician wasn’t lacking patients. In fact, she had a waiting list of patients who wanted to see her. Would a telemedicine offering let her see more patients or charge more for each visit? In this case not at all. It might have had the affect of having some patients call in for appointments rather than show up in person. This could be good or bad development and naturally depends if the time saved or administrative burden relieved out weighs the cost of communication lost from all of the non-verbal cues and clarity of voice, focus or attention that an in-person consultation brings with it. Physicians have their own set of concerns (and all of us in healthcare have moral obligations) related to quality of care. This example is offered not to suggest that digital is either good or bad, but simply that “going digital” without a willingness to fundamentally re-think the implications and ultimately re-configure the underlaying business operations is not the solution.</p><h3>Dominate Your Niche Little Finch</h3><p>The most innovative products often start with a focused niche, develop a competency and strategic advantage within that niche or vertical and expand from there. The <a href="https://suicidepreventionlifeline.org/">Suicide Prevention Lifeline</a> offers an extremely targeted form of telemedicine in one subspecialty, emergency psychiatry. In the same way that AirBnb started as a room renting marketplace and has expanded to a global experiences service and real estate rental brokerage, digital health startups can transform health and wellness. In healthcare, complexity of payment models and regulatory frameworks mean a strategic partner who understands the complexity of the ecosystem is existential when building and executing a digital products. In journalism, we see hyper-targeted sites such as <a href="https://medium.com/">Medium</a> (“read, write and share”), <a href="http://fivethirtyeight.com/">Five Thirty Eight</a> (“statistical analysis and hard numbers”), along with targeted newsletters such as <a href="https://www.ponyexpress.io/subscribe/thetransom">The Transom</a> (“a daily email newsletter for political and media insiders”) succeeding through embracing the digital fabric they are printed on.</p><h3>What to Do</h3><p>In digital health, <a href="http://biemteam.com/">Biem</a> is a great example of business model and service delivery transformation in the transition from physical to digital care (disclosure, I am proud to call Biem a client). If Biem had simply “gone digital with a urology clinic” the product might have just become a telemedicine connection to an appropriate professional. Instead Biem solves the problems that make sexual health hard. It has redefined patient intake, payments, consultation, labs, and communication with peers in ways that leverage the native advantages of digital to offer more than “medicine in an app”. Biem fundamentally changes the healthcare delivery, payment, and communications to improve health for an individual and for a society at large. At risk of this piece becoming a commercial, I’ll stop here and simply point to an <a href="https://youtu.be/r28P1gAagQk">explainer video here</a>.</p><h3>Let’s Do This</h3><p>Digital products are not separate from the businesses behind them. Digital products <em>are</em> the businesses. To succeed in digital health, you must embrace the inherent strengths and capabilities of technology and rethink every aspect of your service. You must innovate from the strategic competencies that made you great in the meatspace. To do so you must build a team with deep knowledge in your health domain, user experience and human centered design in digital products, and of course technical capacity.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe548c15a4dd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>