<?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 ナーム Nam Nguyen on Medium]]></title>
        <description><![CDATA[Stories by ナーム Nam Nguyen on Medium]]></description>
        <link>https://medium.com/@namng?source=rss-bf5424d640a8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*t5B5ZwaNWaMUjgW_oYnMiQ.jpeg</url>
            <title>Stories by ナーム Nam Nguyen on Medium</title>
            <link>https://medium.com/@namng?source=rss-bf5424d640a8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 02:15:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@namng/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[Micro Mobile Frontends in Action: Navigation Registry]]></title>
            <link>https://namng.medium.com/micro-mobile-frontends-in-action-navigation-registry-e76967d7751b?source=rss-bf5424d640a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/e76967d7751b</guid>
            <category><![CDATA[navigation-architecture]]></category>
            <category><![CDATA[ios-architecture]]></category>
            <category><![CDATA[micro-frontends]]></category>
            <dc:creator><![CDATA[ナーム Nam Nguyen]]></dc:creator>
            <pubDate>Sun, 12 Sep 2021 05:19:09 GMT</pubDate>
            <atom:updated>2021-09-12T05:19:09.949Z</atom:updated>
            <content:encoded><![CDATA[<p>If you have ever worked in a large mobile application code base, you would have faced the same issues with many developer that when the Business logic changes, added more flows to the current ones. And the more developers added to the project in term of making faster deliverable product, the messier and longer it takes to have a stable version.</p><p>I’ve been practising many solutions to solve this common issue, with the ultimate purpose that boost up the speed of delivering by adding more people and we still be able to manage everything neat and tidy.</p><p>I’ve been moving the methodology to build a large app ( super-app) from monolith to Micro Frontends architecture, and so far it is going great and mostly solved the problem of many people working in the same codebase.</p><h3>Overall Objectives</h3><p>Since we separated the scope of working that a group of developers will be working on, the structure of the project become much more scalable and easy to develop, maintain and independently deliverable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Z53iQ40GxRUASqTvOeVjA.png" /><figcaption>Mobile Application with Micro Frontends Architecture</figcaption></figure><p>But when it come to integration, which mean we compose all the modularized pieces into one final application, one of the issue is navigation between them. How to make it seamless while a module doesn’t depend on another, so, doing something like below is not applicable</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a7f9b9627d958aedd4f941a10e552465/href">https://medium.com/media/a7f9b9627d958aedd4f941a10e552465/href</a></iframe><h3>Dynamic Customer Journey</h3><p>Eventhough we structure the project in to separated scope, single responsible. But when it came to a real Customer Journey, which allows User go from this module to another, like in the picture</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zxnMQtDn4oJlYHUppdtpTg.png" /><figcaption>Customer Journey from module to module</figcaption></figure><p>User can open the app, come to Newfeeds, then open Profile, and Carts, back to Profile, etc.</p><p>Which means, we must do, somehow, with the modularized architect, it should not against User’s experience whilst they are using the app. Navigating between modules must be seamlessly.</p><p>To have a seamless experience whilst navigating from module to module, while each doesn’t know about another, we came out with a middle layer, which is a coordinator who can help a module to navigate to another’s screen, seamlessly</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vdXe3aafgnRDUy_gd9XWQw.png" /><figcaption>Application as a coordinator</figcaption></figure><h3>Navigation Registry</h3><p>The design of Navigation Registry is a map of routes</p><ul><li>Application level: Map of module</li><li>Module level: Map of screens</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KJAm-ky4cuNt3LX7cRdeuQ.png" /></figure><p>So in practise, if we want to go from a screen inside a module, we will ask ApplicationRegistry to open that screen, without-knowing which module that screen belongs to.</p><h3>Concept</h3><p><strong>MAFModuleRegistry</strong></p><p>A shared module, which defines the protocols for NavigationRegistry</p><ul><li>Application level: <em>MAFNavigationRegistry</em></li><li>Module level: <em>MAFModuleRegistry</em></li></ul><p><strong>UserModule’s registry</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c787c577397e3e746de5f6429407b012/href">https://medium.com/media/c787c577397e3e746de5f6429407b012/href</a></iframe><p>Same with NewsFeedModule and another modules</p><p><strong>ApplicationRegistry</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3ecf276fe2838b4d706bae510aeeb430/href">https://medium.com/media/3ecf276fe2838b4d706bae510aeeb430/href</a></iframe><p><strong>Navigating from a Module</strong></p><p>POV: You are working in Newfeeds module and you want to open User’s profile ( which is a part of UserModule ). This is how</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fee5b375ffc7ac6591b75b315a5ba66e/href">https://medium.com/media/fee5b375ffc7ac6591b75b315a5ba66e/href</a></iframe><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/296/1*UTMq0HJv4RF0dbFVqW7nbQ.gif" /></figure><p>It is that simple.</p><h3>Special case</h3><p>Becase every module is developed by an independent team, so, there will be senariors that the screen we want to open is not ready (yet). There are few ways to handle this senarios</p><ul><li>Ignore ( do-no-thing) if the screen is not ready</li><li>Display an error message: “Route/screen not found”</li><li>Show a default screen (404-Page-Not-Found)</li></ul><p>I prefer the last option, which is showing the default screen page not found :). The experience will look like this</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/91fb414d8b60ad0b5cc037d67add5886/href">https://medium.com/media/91fb414d8b60ad0b5cc037d67add5886/href</a></iframe><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*p6L8Wz4p_bJdLa_NOFNjUA.gif" /></figure><h3>Conclusion</h3><p>The article here I just show the basic concept of how we designed the Navigation Registry. Furthermore, I’ve been developing the MAFNavigationRegistry to support more type of navigating like present, half-screen present, alert, action-sheets, etc.</p><p>The source code in the demo is <a href="http://git@github.com:nhnam/NavigationRegistryDemo.git">here</a>. Please feel free to try it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e76967d7751b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SafeMode in UserDefaults]]></title>
            <link>https://namng.medium.com/safemode-in-userdefaults-3db5b3a4dc73?source=rss-bf5424d640a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/3db5b3a4dc73</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[better-programming]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[ナーム Nam Nguyen]]></dc:creator>
            <pubDate>Sun, 21 Mar 2021 06:11:06 GMT</pubDate>
            <atom:updated>2021-03-21T06:15:51.443Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*ecqNnXk_9q3X9D_22z-KPA.jpeg" /><figcaption>This image is just for fun :)</figcaption></figure><p>UserDefaults is a built-in Utility included in Foundation. It allows Developers to save User’s settings with one line call.</p><blockquote>NSUserDefaults has a list of places to look for data called the “search list”. A search list is referred to by an arbitrary string called the “suite identifier” or “domain identifier”. When queried, NSUserDefaults checks each entry of its search list until it finds one that contains the key in question, or has searched the whole list. (Apple)</blockquote><p>Basically, It performs perfectly for most of the cases. But let imagine that you are 2 peoples working on the same project, which will use the same UserDefaults instance. And one day, your friend accidentally overrides your settings, which makes your feature turn into unexpected behavior.</p><p>I think it’s better if we can use UserDefaults in a concerned, be awarded way. Like if we want to save an item into UserDefaults, we want to make sure that if won’t be overridden without our very-sure permission.</p><p>So I wrote a Swift Package called <a href="https://github.com/nhnam/SafeUserDefaults">SafeModeUserDefaults</a> :), like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0184cd1d63037242bf49b175eab0c9a8/href">https://medium.com/media/0184cd1d63037242bf49b175eab0c9a8/href</a></iframe><p>The mechanism is before saving Item to UserDefaults, it will ask back in case need permission to override, that’s it, very simple.</p><p>For more use-cases, you can check the Document in the Package.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/309313e7ee8348feeec80b342a7b6c05/href">https://medium.com/media/309313e7ee8348feeec80b342a7b6c05/href</a></iframe><p>If you find it’s helpful for you, try it.</p><p>If you find any bug or suggestions, please feel free to create a PR or raise an issue, I will look into it and fix it.</p><p>In the next steps, I would like to apply the same mechanism for another storage like Keychains.</p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3db5b3a4dc73" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Practice React Native: Creating your own Native Module]]></title>
            <link>https://namng.medium.com/practice-react-native-creating-your-own-native-module-3a379c5a4baf?source=rss-bf5424d640a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a379c5a4baf</guid>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[ナーム Nam Nguyen]]></dc:creator>
            <pubDate>Sun, 02 Dec 2018 15:58:00 GMT</pubDate>
            <atom:updated>2020-01-21T02:47:09.299Z</atom:updated>
            <content:encoded><![CDATA[<p>Sometime when we need a specific way to interact with the phone or operator system which is various different between iOS and Android, that when we need to lean that responsibility to the OS it self.</p><p>In RN, most of the logic and UI, in the best way, must be consistent between platforms. So, In an advance level of bringing best user experience to end user, we need to create native module, that mean the leaning the logic to the Native Part. There are ton of article out there showing why and when we need to create a native module, I won’t dive into explanation again. Instead, I will show you how can we create a native module that could be used in React native code. That mean, you write your Objective-C/Java code, and import and run it as a module in Javascript Code.</p><p>I will show you here the most basic way to create the most basic library, called: open <a href="https://google.com/">https://google.com</a>. It means, I want to open Google by using the default iOS/Android browser in a native way.</p><h3>Creating react-native-browser.</h3><p>First, we need to have the development environment ready for working in react-native. I suppose that you have npm, node, react-native-cli, VSCode, yarn, XCode, Android-Studio, Chrome, iOS Simulator, Android Emulator installed.</p><blockquote><em>Recommended: You should check if you have Java 1.7+ installed. The best version I experienced that works perfectly for React Native development is Java 1.8. Open your Terminal:<br> </em><em>brew tap caskroom/versions<br> </em><em>brew cask install java8</em></blockquote><h3>Install react-native-create-library</h3><p>The most convenient way is using react-native-create-library to create a dependency that could be imported in React Native. You can install it as a global dependency by using npm install -g react-natice-create-library.</p><h3>Create dependency name browser</h3><p>After installed react-native-library successfully, now, it’s time to create our first dependency. react-native-create-library browser --package-identifier com.mylibs --platform ios,android</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/0*j5nJQqRTa06p3mHn.png" /></figure><p>After that, you will see that we have a new folder called browser which is the dependency that just created.</p><blockquote><em>To be consistent, or, in another call, to be easy to identify your library when you need to publish it to </em><em>npm registry and allow the community to use, we should rename it to </em><em>react-native-browser<br> </em><em>mv browser ./react-native-browser</em></blockquote><p>After creating our dependency called browser we have a structured folder:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*Oskk7sjKKHv8cmXq.png" /></figure><blockquote><em>tree is a library I use to print a folder structure in terminal. you also can install it by using HomeBrew:<br> </em><em>brew install tree</em></blockquote><blockquote><em>When create new library by using </em><em>react-native-create-library, there was a parameter called </em><em>--platform, default value is </em><em>ios,android,windows, means if you don&#39;t provide which platforms you want our dependency to support, it will generate 3 folders for iOS, Android, Windows. Since we don&#39;t support Windows in this demo, I will remove the windows folder.</em></blockquote><blockquote><em>cd react-native-browser</em></blockquote><blockquote><em>rm -rf windows</em></blockquote><h3>Analyse dependency folder</h3><p>Basically, Javascript communicate with our module via a bridge, so, it have no idea about our native code. The concept is that the developers who will use our library will lean on what we define/export/allow them to call. If you can see in our folder, there is a javascript file named index.js. Let take a look into that file.</p><p>The responsibility of index.js is export public functions for another developer to use it in their project. We need to call our NativeModules here and export it out. Sounds like a bridge, or a wrapper exactly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VGbuI7QT5iMYVIuh.png" /></figure><blockquote><em>cat is used to print out the content of a file, in text.<br> </em><em>cat index.js will print </em><em>index.js out right in the terminal.</em></blockquote><p>As we see, the purpose of index.js just export our Module as default, nothing else. But in best practise, we usually do another thing in index.js as a convenient wrapper specified for each platform, so, better we provide different module.exports .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Tmzq2msjD4VjYylW.png" /></figure><h3>Add your new Module in to project</h3><p>Before we continue writing our own code in the native module, I recommend you link it in to project, it’s easier for us to code in a compile-able project rather than typing without any awareness.</p><p>Copy your library folder react-native-browser into node_modules. Link your current module to react-native NativeModules by using react-native link react-native-browser</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dRD_AOy_-MCVefy4.png" /></figure><p>Then, we will continue editing our Module in node_modules/react-native-browser/ios or node_modules/react-native-browser/android instead of the folder we just created.</p><h3>Write some dump function in your NativeModules</h3><p>After linking our library to Demo project, inside the iOS Project of DemoBrowser, you will see our NativeModule has been attached</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/0*DgyF1YEhHaX8UQ2G.png" /></figure><h4>iOS Perspective</h4><p>Look again at the folder tree above, we can see that there are RNBrowser.h and RNBrowser.m inside the ios folder. That is the implementation of iOS Native Module RNBrowser, quick look at the implementation of RNBrowser</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Mw2m20MXsA8rBPBW.png" /></figure><p>RCT_EXPORT_MODULE() : means our Module will have the name as the class name - RNBrowser, or, if you want, you can specific the name you like, but, just make sure that you also change the Module name in the index.js in iOS&#39;s part.</p><blockquote><em>Change to another name: </em><em>RCT_EXPORT_MODULE(NewAwesomeBrowserModule)<br> in </em><em>index.js platform iOS: </em><em>NewAwesomeBrowserModule.openGoogle();</em></blockquote><p>Now it’s time to write our Module’s method openGoogle in native way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*P229eRqaI3VruGLE.png" /></figure><p>That’s it, we can try some improvement, but that is pretty enough for opening Google.</p><p>Now we back to our demo to see how to use our native module: Open DemoBrowser/App.js then import our Module&#39;s method:</p><p>import { openGoogle } from &#39;react-native-browser&#39;;</p><p>Then we add a Button which is just for Open Google.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*t1xg0M8YLILkVb6B.png" /></figure><p>Now, it’s time to run the Demo to se how does it work. DemoBrowser&gt; react-native run-ios</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*O_hoNVWAQaV0Xp85.gif" /></figure><p>It works perfectly as we expected. Nothing much but it’s how we import Native Module to React-Native code. In the next Tutorial, I will explain more about various type of Macros such as RCT_EXPORT_MODULE(), RCT_EXPORT_METHOD(), and how we use them for various purpose, also how we implement the same method on Android. The final step would be publish your awesome library to npm&#39;s registry.</p><p>Good luck and happy coding!</p><p><em>Originally published at </em><a href="https://gist.github.com/nhnam/ca76872d2fc92ed3ce5034c6a32878eb"><em>gist.github.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a379c5a4baf" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>