<?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 Luc Duzan on Medium]]></title>
        <description><![CDATA[Stories by Luc Duzan on Medium]]></description>
        <link>https://medium.com/@stroky.l?source=rss-e5180819cecf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*OD-DInusjrG-Wf0O.</url>
            <title>Stories by Luc Duzan on Medium</title>
            <link>https://medium.com/@stroky.l?source=rss-e5180819cecf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 05:28:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@stroky.l/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[Crossing street in Hanoi]]></title>
            <link>https://medium.com/linagora-engineering/crossing-street-in-hanoi-6eb9b4351f18?source=rss-e5180819cecf------2</link>
            <guid isPermaLink="false">https://medium.com/p/6eb9b4351f18</guid>
            <category><![CDATA[traffic]]></category>
            <category><![CDATA[vietnam]]></category>
            <category><![CDATA[travel]]></category>
            <dc:creator><![CDATA[Luc Duzan]]></dc:creator>
            <pubDate>Sun, 05 Nov 2017 11:22:18 GMT</pubDate>
            <atom:updated>2017-11-07T15:35:46.502Z</atom:updated>
            <content:encoded><![CDATA[<p>I have the luck to work for an international company, <a href="https://medium.com/linagora-engineering">Linagora</a>, and especially in a team with members from different locations (multiple cities in France, Tunis and Hanoi).<br>So I had the opportunity to travel to Asia for the first time in order to do a Barcamp about ElasticSearch use in <a href="https://james.apache.org/">James</a>. But for this article, I am not going to speak about technical stuff, I am going to give a tutorial about how to cross a street here.</p><p>Because yes, the first time you will arrive in Vietnam, one of the first thing that will strike you is the traffic. It is way more intense, anarchic/chaotic/auto-organised and two wheels oriented than in Europe!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FMiNa73bw4vM%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DMiNa73bw4vM&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FMiNa73bw4vM%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/187c8f10147494aab930ae37ecea161d/href">https://medium.com/media/187c8f10147494aab930ae37ecea161d/href</a></iframe><p>So if you try to cross a street like in Europe waiting that there is no car and no scooter, you will probably enter into a deadlock situation until it reaches 2 a.m.<br>In fact, you have three strategies to success in this complicated mission.</p><p>Strategy number one is to wait that a local guy, for example a grandpa, want to cross the same street than you and just follow him side by side without looking the traffic surrounding you (otherwise you might get a heart attack).</p><p>Strategy number two, just stop thinking as an European and be brave. You have to take into consideration that here the traffic is mainly made of scooter so it is easy for them to avoid you as long as you move in a PREDICTABLE WAY. Being predictable is the key, so don’t stop suddenly, don’t cross by running, don’t turn!<br>As always a good way to achieve your goal is to divide it in multiple steps. So when you cross the street try to move one meter by meter, do not be afraid to make some stop in the middle of the street as long as you did it in a predictable way.<br>While doing this you need to focus strongly on the traffic and be careful people can come from any direction!<br>The issue is that staying focus is not easy as you can see a lot of surprising stuffs in Hanoi’s traffic that can disturb you:</p><ul><li>a full family on one scooter</li><li>girl dressed in a very fancy way with spike heel driving motorbikes</li><li>a guy walking his pets/foods using the scooter in the middle of this crazy traffic</li><li>Vietnameses can carry anything on a scooter: sofa, chair, huge tank of water, alive pig etc…</li><li>and also quite a lot of thinks to sell on a bike: fruits, street food etc…</li></ul><p>Strategy number three (suggested by a Vietnamese co-worker) close your eyes and just cross!</p><p>But don’t worry after a while you will get used to it and you might find that crossing street here is faster than in Europe because you do not have to wait for the traffic to stop. After one week here I can even succeed to bike in the traffic!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6eb9b4351f18" width="1" height="1" alt=""><hr><p><a href="https://medium.com/linagora-engineering/crossing-street-in-hanoi-6eb9b4351f18">Crossing street in Hanoi</a> was originally published in <a href="https://medium.com/linagora-engineering">Linagora Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Caching REST calls when offline]]></title>
            <link>https://medium.com/linagora-engineering/caching-rest-calls-when-offline-768566c18e04?source=rss-e5180819cecf------2</link>
            <guid isPermaLink="false">https://medium.com/p/768566c18e04</guid>
            <category><![CDATA[offline]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[angularjs]]></category>
            <dc:creator><![CDATA[Luc Duzan]]></dc:creator>
            <pubDate>Wed, 21 Jun 2017 08:40:05 GMT</pubDate>
            <atom:updated>2017-06-22T14:01:09.386Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L4rF1pV0YeKF31uF8wmbHA.jpeg" /></figure><p>Some members of the <a href="http://open-paas.org/">OpenPaas</a> team and Linshare team had a meeting in Agde for a <a href="https://medium.com/linagora-engineering/story-of-a-barcamp-afe51e59e7f0">desktop bar-camp</a>. The aim was to produce a desktop version of OpenPaas using Electron that will also support offline mode. While a part of the team was working <a href="https://medium.com/linagora-engineering/building-a-desktop-openpaas-application-f688ff5f803c">on packaging OpenPaas into Electron</a> the rest of the team has been working on offline support.<br>The first use case is to let the user organize his emails and his calendars when offline.<br>All the actions done offline are saved and sent to the server once the client regain network connection.</p><h3>Architecture of the solution</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/234/1*1jLaavZYgByqAWIpxsYCQA.png" /></figure><p>Firstly, we wanted a solution that could be turned on and off (feature flipping) and that did not ask for a lot of modifications on the back-end part. The only requirement of the back-end is to detect concurrent modification. This is already the case for event (thanks to <a href="https://github.com/owncloud/client/wiki/Etags-and-file-ids">E-Tag</a> of WebDav) and for email (thanks to ifInState of <a href="http://jmap.io/spec-mail.html#setmailboxes">JMAP spec</a>).</p><p>Our main idea was to add a generic angular service<a href="https://ci.open-paas.org/stash/projects/OR/repos/rse/browse/frontend/js/modules/esn.lr.offline.js?at=refs%2Fheads%2Foffline_merge">, offlineApi</a>, to ease the support of offline mode for OpenPaas module. This service responsibility is to store actions when the user is offline and send them to the server when the user regains connection. It should also notify module that use the offlineApi of the actions’ state.</p><p>Each module that wants to support offline mode needs to register all the different actions which need to interact with the server. This is done using:</p><pre>offlineApi.registerActionHandler(<br>  module: string,<br>  action: string,<br>  callback: localRecord -&gt; restangular result<br>)</pre><p>The type of local record will be defined below. The <em>module</em> parameter is to avoid collisions across module that might want to register actions with the same name. The <em>action</em> parameter identify a kind of action, for example “create an event”, “remove an event”. The callback will be called with all the necessary informations to perform the action by the local record passed as an argument.</p><p>The local record is an object with the following fields:</p><ul><li>module: string</li><li>action: string</li><li>payload: object, it can be anything and it is defined by the module when calling <em>offlineApi.recordActio</em>n.</li></ul><p>When the module have recorded all the different kinds of action he needs, instead of directly doing a request to the server, it can now call <em>offlineApi.recordAction</em> by passing a local record. The module can use the payload field to pass all necessary informations to perform the action on the server. For example, in the case of an event creation this could be a jCal object.</p><p>When <em>offlineApi.recordAction</em> is called, our module will check if we are offline or online:</p><ul><li>if we are offline, the callback registered before will not be called yet and the local record will be stored on the browser using <a href="https://github.com/localForage/localForage"><em>localForage</em></a>. Once the network is back, we will fire the callback on it.</li><li>if we are online, we will also register the local record in case we get a time-out exception (offline situation that has not been detected). Then we fire the callback and only remove the local record on success or error but not on time-out error.</li></ul><p>The <em>offlineApi.recordAction</em> returns a promise that resolves with the localRecord after adding an id to it so we can easily delete it later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GN6gP6RhAOeNP5zf5Rkn-Q.jpeg" /></figure><h3>Offline detection</h3><p>At the beginning, we had the idea to use <a href="https://developer.mozilla.org/en-US/docs/Web/API/NavigatorOnLine/onLine">window.navigator.online</a>, but it turn out to be a bad idea because the definition of offline is not the same across browser and at best it detects offline when the network interface is down!<br>So we got the idea to take advantage of the websocket already in place on OpenPaas, in fact websocket connection have two interesting events:</p><ul><li>onConnect</li><li>onDisconnect</li></ul><p>It turned out to work pretty well during our experimentations.</p><h3>Optimisation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lZ6VWKqh5vFDXkymBXmYBg.jpeg" /><figcaption>An example of place optimisation</figcaption></figure><p>We have also added a <em>listActions</em> method to our <em>offlineApi</em> that allows us to list all the actions waiting for connection. The idea is that sometime, a new action can replace an old action. This brings the opportunity for a module to inspect its own actions and remove them with the help of <em>offlineApi.removeAction</em>.</p><p>For example, in the case of the calendar module, any modification or deletion on an event removes all previous pending creations or modifications about this event. So when the user regains connection instead of doing two sequential requests, we merge them into one that will have the same effect.</p><p>The <em>offlineApi.listActions</em> is also really important if the web application get refreshed when offline. The module needs to be able to know unfinished operations from previous session. For example, in the calendar when reloading the web application we look for all pending creation/deletion to display them correctly.</p><h3>Conclusion</h3><p>During the bar-camp, we were able to add offline support for CRUD operations on event for the calendar module.</p><p>The most difficult part was to consider that the feedback of a CRUD operation on the server does not come anymore from a promise but from a callback that can be called potentially an hour or even some days later, after a total refresh of the application (reboot of a laptop after a flight for example).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*uamxBZ2q_cj-cfgO7drLZQ.png" /></figure><p>You then need to be able to pretend the action has been done and to be prepared to revert it at any time.</p><p>Working on offline support is something challenging and it was really enjoyable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iKfvzy8orogjIWT5FYf2_A.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=768566c18e04" width="1" height="1" alt=""><hr><p><a href="https://medium.com/linagora-engineering/caching-rest-calls-when-offline-768566c18e04">Caching REST calls when offline</a> was originally published in <a href="https://medium.com/linagora-engineering">Linagora Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>