<?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 Michael De Abreu on Medium]]></title>
        <description><![CDATA[Stories by Michael De Abreu on Medium]]></description>
        <link>https://medium.com/@michaeljota?source=rss-bfe37c875817------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*g9QjM8KUt7R9D_7zjQwwTw.jpeg</url>
            <title>Stories by Michael De Abreu on Medium</title>
            <link>https://medium.com/@michaeljota?source=rss-bfe37c875817------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 01:47:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@michaeljota/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[Integrating an Angular-CLI application with Electron]]></title>
            <link>https://medium.com/@michaeljota/integrating-an-angular-cli-application-with-electron-653955299c87?source=rss-bfe37c875817------2</link>
            <guid isPermaLink="false">https://medium.com/p/653955299c87</guid>
            <category><![CDATA[electron]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Michael De Abreu]]></dc:creator>
            <pubDate>Mon, 08 Jan 2018 17:06:09 GMT</pubDate>
            <atom:updated>2018-01-08T17:06:09.423Z</atom:updated>
            <content:encoded><![CDATA[<p>Electron is a platform to develop desktop applications using web technologies like HTML, CSS and JS. Integrate a ng-cli application with Electron is more straightforward that it may seems.</p><h3>Electron’s two package structure</h3><p>If you are familiarized with Electron you may remember the two package structure. We will use a similar structure, but with a key difference: In a regular two package structure, the /app/ folder will contains the Electron app. We will name this folder /electron/ and another /app/ folder inside will contains our compiled Angular application.</p><p>It may seem like we are using the two package structure, but we are just separating the Electron part from the rest of the application.</p><h3>Changes in the app configuration</h3><ul><li>Create a script in our Angular application package.json.</li></ul><pre>&quot;electron:start&quot;: &quot;ng build --watch -op=electron/app&quot;</pre><p>This will build the Angular app inside an app folder inside our Electron folder app, and will rebuild on every change.</p><ul><li>Add the new output folder into .gitignore, in #compiled output section, /electron/app.</li><li>Modify the base tag of the index.html of our Angular app, as follow:</li></ul><p>Adding a dot before the slash will allow Electron to find the served files, and without a 404 error will be threw.</p><p>This will be all the modifications that we need to integrate the application with Electron.</p><h3>Creating our Electron app</h3><ul><li>We need to create a electron folder inside our project. Inside we are going to run npm init command to create the Electron package.json. This folder will be our Electron root folder.</li><li>We add Electron as a development dependency.</li><li>We create the entry point for our Electron program.</li></ul><p><em>index.js</em></p><pre>const { app, BrowserWindow } = require(&#39;electron&#39;);<br>const path = require(&#39;path&#39;);<br>const url = require(&#39;url&#39;);<br>// Keep a global reference of the window object, if you don&#39;t, the window will<br>// be closed automatically when the JavaScript object is garbage collected.<br>let win;<br>function createWindow() {<br>  // Create the browser window.<br>  win = new BrowserWindow({ width: 800, height: 600 });<br>  // and load the index.html of the app.<br>  win.loadURL(<br>    url.format({<br>      pathname: path.join(__dirname, &#39;app&#39;, &#39;index.html&#39;),<br>      protocol: &#39;file:&#39;,<br>      slashes: true,<br>    }),<br>  );<br>  // Open the DevTools.<br>  win.webContents.openDevTools(); <br>  // Emitted when the window is closed.<br>  win.on(&#39;closed&#39;, () =&gt; {<br>    // Dereference the window object, usually you would store windows <br>    // in an array if your app supports multi windows, this is the time<br>    // when you should delete the corresponding element.<br>    win = null;<br>  });<br>}</pre><pre>// This method will be called when Electron has finished<br>// initialization and is ready to create browser windows.<br>// Some APIs can only be used after this event occurs. app.on(&#39;ready&#39;, createWindow);</pre><pre>// Quit when all windows are closed.<br>app.on(&#39;window-all-closed&#39;, () =&gt; {<br>  // On macOS it is common for applications and their menu bar<br>  // to stay active until the user quits explicitly with Cmd + Q<br>  if (process.platform !== &#39;darwin&#39;) {<br>    app.quit();<br>  }<br>});</pre><pre>app.on(&#39;activate&#39;, () =&gt; {<br>  // On macOS it&#39;s common to re-create a window in the app when the<br>  // dock icon is clicked and there are no other windows open.<br>  if (win === null) {<br>    createWindow();<br>  }<br>});</pre><pre>// In this file you can include the rest of your app&#39;s specific main process<br>// code. You can also put them in separate files and require them here.</pre><h3>Running the app</h3><ul><li>Open a terminal and move to the Angular project, and run npm run electron:start to start the Angular application.</li><li>Open a second terminal and move to the electron folder inside the project, and run electron . to start the electron application.</li></ul><p>You should see a window with the Angular app running inside of it.</p><h3>Moving forward</h3><p>We now have a very simple Angular application running inside of the Electron renderer process. If we modify something of either, the Angular app, or the Electron app, we need to close the Electron window and run the electron . again. This could be optimize using plugins and build systems, but this is the out-the-box behavior of Electron.</p><p>You may notice that the entry file of the Electron application is written in vanilla Javascript. This is because Electron runs only vanilla Javascript, and in order to run other language such Typescript, you should use a plugin, such ts-node, or a build system.</p><p><em>Originally published at </em><a href="https://dev.to/michaeljota/integrating-an-angular-cli-application-with-electron-34mi"><em>dev.to</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=653955299c87" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The GitHub repos I discovered this week]]></title>
            <link>https://medium.com/@michaeljota/the-github-repos-i-discovered-this-week-336930c62a0d?source=rss-bfe37c875817------2</link>
            <guid isPermaLink="false">https://medium.com/p/336930c62a0d</guid>
            <category><![CDATA[github]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Michael De Abreu]]></dc:creator>
            <pubDate>Sun, 22 Oct 2017 22:42:52 GMT</pubDate>
            <atom:updated>2017-10-22T22:42:52.195Z</atom:updated>
            <content:encoded><![CDATA[<p>Is Sunday, and this week is finishing. But I notice that this week I spend a unmeasured amount of time playing around with the new GitHub feature, Discover. The explore just show you a list of repositories that you may like, as Facebook show you pages that you may like. This is really good, cause I always have see GitHub as a social network, and it’s now becoming one; and it’s also very interesting to <em>discover</em> new repositories. In this post, I just want to share with you a little list with some of the repositories I add this week, and a little something about why I add it.</p><p>You need to notice that when I say add, I mean star. The order does not matter and does not implies any preference.</p><h3><a href="https://github.com/prettier/prettier">Prettier</a></h3><p>Prettier is an opinionated code formatter. Or that’s what they say. I have to say, I use the build-in formatter of the VSCode most of the time, (switch+alt+f). But the flaw is that you can&#39;t format HTML properly, and if you know who please, leave a comment. That&#39;s why I added Prettier. Right now it support JS (ES2017, TS, JSX, Flow), CSS (SCSS, LESS), JSON and GraphQL. But they are working in support HTML and templates.</p><h3><a href="https://github.com/pureqml/qmlcore">QMLCore</a></h3><p>QML is a user interface markup languages, JSON-like. It was love a first sight, although it was being used for Sailfish app, I love it. So I suddenly become interest in something that allows me to compile QML to HTML, and QMLCore is just that. I have not play around with that yet, but still.</p><h3><a href="https://github.com/nestjs/nest">nest</a></h3><p>I read about this in the Node Weekly newsletter. I love decorators, this is one of the reasons I fall in love with Angular so quickly, and nest use them for server side development in a way that just fell right.</p><h3><a href="https://github.com/facebook/prepack">Prepack</a></h3><p>Ok, this maybe know, as well as Prettier, but I find out this week about this. This evaluates your JS code going one step beyond the tree shaking. I like it very much, and I want to see how this evolve. I still don’t have that confidence with the Facebook products, but it’s really OSS, so if anything, the community will continue the work.</p><p>So this was all for this week. I hope I can pick others repos in the forthcoming future and write about them.</p><p>As always, a pleasure to write to you guys.</p><p><em>Originally published at </em><a href="https://dev.to/michaeljota/the-github-repos-i-discovered-this-week-2mg"><em>dev.to</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=336930c62a0d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Input-Set pattern for Widgets in Angular]]></title>
            <link>https://medium.com/@michaeljota/input-set-pattern-for-widgets-in-angular-5a461548d0f4?source=rss-bfe37c875817------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a461548d0f4</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[web-components]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Michael De Abreu]]></dc:creator>
            <pubDate>Sun, 22 Oct 2017 16:44:22 GMT</pubDate>
            <atom:updated>2017-10-22T16:44:22.431Z</atom:updated>
            <content:encoded><![CDATA[<p>If you read my last post, you should know what a Widget is, if you haven’t already, do it now, I’ll <em>await</em>.</p><p>await Reader.read(&#39;<a href="https://dev.to/michaeljota/widgets-and-components-for-angular-2-and-up">Widgets and components</a>&#39;);</p><p>Now you know what Widgets should be. I tried to keep it simple for the first implementation, but I’m really turning my head around this. The thing is, React is a JavaScript pure framework and with JSX allow us to do things that we can’t made with plain HTML templates, nevertheless, Typescript allow us for things that JavaScript does not, at the very least, it seems to allow that. Like <em>private</em> properties. With that in mind, I’ll try to explain why you should use private properties inside a Widget and how to manage the data entry in a better way.</p><h3>The situation</h3><p>Following the comparative with React from the last post, when the props are send to a component, most of the the time we are getting it following the destructive pattern, allowing to do things like:</p><pre>interface IUser {<br>  firstname: string;<br>  lastname: string;<br>  age: number;<br>}</pre><pre>export function usersList({users = []} : { IUser[] }) {<br>  return (<br>    &lt;ul&gt; users.map(user =&gt; userDetails(user)); &lt;/ul&gt;<br>  );<br>}</pre><pre>function userDetails({firstname, lastname, age}: IUser) {<br>  return (<br>    &lt;li&gt;&lt;span&gt;{firstname} {lastname}&lt;/span&gt; have {age} years old&lt;/li&gt;<br>  );<br>}</pre><p>I think this looks good, because it allow us to be explicit about what we want to show, and how to show it.</p><p>In Angular, we just @Input the data that we want to get from the outside.</p><pre>// user.ts<br>interface IUser {<br>  firstname: string;<br>  lastname: string;<br>  age: number;<br>}<br>// user-list.widget.ts<br>import { Component, Input } from &#39;@angular/core&#39;;</pre><pre>@Component({<br>  selector: &#39;my-user-list&#39;,<br>  template: `<br>    &lt;ul&gt;<br>      &lt;li *ngFor=&quot;let user of users&quot;&gt;<br>        &lt;my-user-details [user]=user&gt;&lt;my-user-details&gt;<br>      &lt;/li&gt;<br>    &lt;/ul&gt;<br>  `,<br>})<br>export class UserListWidget {<br>  @Input()<br>  public users: IUser[]; <br>}</pre><pre>// user-details.widget.ts<br>import { Component, Input } from &#39;@angular/core&#39;;</pre><pre>@Component({<br>  selector: &#39;my-user-details&#39;,<br>  template: `<br>    &lt;span&gt;{{user.firstname}} {{user.lastname}}&lt;/span&gt; has {{user.age}} years old<br>  `, <br>})<br>export class UserDetailsWidget {<br>  @Input()<br>  public user: IUser;<br>}</pre><p>This is right, as Widgets are suppose to display data, and they should <em>only</em> concern should be how to display that data. But we need a better way to organize how we show that data correctly in the template.</p><p>I like the approach from React in that sense. Don’t get me wrong, I love Angular. But JSX allow us to do something nicer than dotted properties, destructive assignment.</p><h3>Solution proposal</h3><p>Now that is being clearer that React have a somewhat advantage above us, we as Angular developers need to propose a solution to be even, using features that are being bringed by Typescript, <em>private</em> properties. I know that Typescript is compiled to JavaScript, and JavaScript doesn’t have such things, but, we’ll do as we don’t care.<br> Also, we will use a ES6 set feature. This allow us to have properties that can be set, but cannot be read.</p><h3>Introducing @input set</h3><pre>import { Component, Input } from &#39;@angular/core&#39;;</pre><pre>@Component({<br>  selector: &#39;my-user-details&#39;,<br>  template: `<br>    &lt;span&gt;{{_user.firstname}} {{_user.lastname}}&lt;/span&gt; has {{_user.age}} years old<br>  `,<br>})<br>export class UserDetailsWidget {<br>  private _user: IUser; <br>  @Input()<br>  public set user(value: User): void {<br>    this._user = value;<br>  }<br>}</pre><p>OK. We learn we can set to private properties, but that does not quite allow us to show the properties in the template. Technically JavaScript only have properties, so we could bind to the private property, but we should <em>never</em> bind a private property to the template, as the AOT compiler would throw.</p><h3>Introducing template get</h3><pre>@Component({<br>  selector: &#39;my-user-details&#39;,<br>  template: `<br>    &lt;span&gt;{{firstname}} {{lastname}}&lt;/span&gt; has {{age}} years old<br>  `,<br>})<br>export class UserDetailsWidget {<br>  private _user: IUser;<br>  @Input()<br>  public set user(value: IUser) {<br>    this._user = value;<br>  }<br>  public get firstname(): string {<br>    return this._user.firstname;<br>  }<br>  public get lastname(): string {<br>    return this._user.lastname;<br>  }<br>  public get age(): age {<br>    return this._user.age;<br>  }<br>}</pre><p>This actually works as expected. Allowing a better control over the data that are being displayed in the template, and how to expose it. Also, it would even allow us to do certain things, to maintain the code in a better way.</p><pre>@Component({<br>  selector: &#39;my-user-details&#39;,<br>  template: `<br>    &lt;span&gt;{{fullname}}&lt;/span&gt; has {{age}} years old<br>  `,<br>})<br>export class UserDetailsWidget {<br>  private _user: IUser;<br>  @Input()<br>  public set user(value: IUser) {<br>    this._user = value;<br>  }<br>  public get fullname(): string {<br>    return `${this._user.firstname} ${this._user.lastname}`;<br>  }<br>  public get age(): number {<br>    return this._user.age;<br>  }<br>}</pre><p>However, template get as showed here have certain issues, but I&#39;ll explain everything about those issues properly in other post.</p><h3>Example</h3><p>For this, I made a little Plunker that expose the use case. <a href="http://plnkr.co/edit/qQMk8kCH0wWp3yznE6MX?p=preview">Here</a></p><h3>Thanks you</h3><p>As always, thank you for reading this long. I hope you like it, and I am really looking forward to read your thoughts in the comments section.</p><p><em>Originally published at </em><a href="https://dev.to/michaeljota/input-set-pattern-for-widgets-in-angular"><em>dev.to</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a461548d0f4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Widgets and Components for Angular 2 and up]]></title>
            <link>https://medium.com/@michaeljota/widgets-and-components-for-angular-2-and-up-42b0bb28794c?source=rss-bfe37c875817------2</link>
            <guid isPermaLink="false">https://medium.com/p/42b0bb28794c</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[web-components]]></category>
            <dc:creator><![CDATA[Michael De Abreu]]></dc:creator>
            <pubDate>Sun, 22 Oct 2017 16:21:16 GMT</pubDate>
            <atom:updated>2017-10-22T16:21:16.922Z</atom:updated>
            <content:encoded><![CDATA[<p>If you are comming from React, the React community as develop some patterns that made easy and simple to develop apps with this framework. One of this patterns is the <em>smart</em> and <em>dumb</em> component, or <em>container</em> and <em>component</em>. This keeps a separation between how a component should display the data, and how a component actually manage the data. If you want more about this, there are plenty of articles about it, this is not what I’m writing about.</p><h3>Situation</h3><p>The actual name for a piece of web page according to the standard it’s “web component”, so one might think that calling <em>component</em> to the piece of code that shows the data it’s the most accurate way to name them. But…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*hd9z20cnF6fTuYWq.jpg" /></figure><p>Angular community had develop their own way of thinking about what a component is, and in the Angular community I had see so many times that a <em>component</em> have a <em>behavior</em>.</p><blockquote><em>What?! This is just insane. A component should concern only about how to display the data, no how to manage it.</em></blockquote><p>Well, it is true. The only fact that Angular components are called <em>Components</em> it’s one of the examples to show my point of view. Still, we need some way to manage the display of the data.</p><h3>Solution proposal</h3><p>I know this would be only another solution proposal, and mine doesn’t actually adds anything to current implementation, it’s just syntactic sugar for the same thing.</p><h3>Introducing Widgets</h3><p>So… Widgets? What <em>should</em> they be? I propose <em>Widgets</em> to name anything that only should concern about how to display something. And this it’s something that Angular it’s great at, separation. I’m not saying that React it’s bad about it, but I think that the Angular team had a better approach to this issue.</p><p>Ideally a Widget should have only @inputs and @outputs. That&#39;s all. A Widget had to be made to show info, and it have to be a component that reflects that in their code. There should be no logic inside a Widget, but the logic that a Widget need to show the data that is being inputed.</p><p>I also think about the way that the data should be managed inside the Widget, but that would be for another day (Or you can read this <a href="https://github.com/mgechev/codelyzer/issues/222">issue</a>)</p><h3>What widgets should be</h3><ul><li>Widgets should be the presentation components of and Angular application.</li><li>Widgets should be logicless.</li><li>Widgets should be concern about the style of their own data.</li></ul><h3>Questions</h3><ul><li>Widgets are just <em>components</em>?</li></ul><p>Yes. :). No more, not less. Just <em>components</em>. They have to show information, but they should not care about how the information it’s being provide for them.</p><ul><li>Why another name then?</li></ul><p>As I said, <em>component</em> in Angular community had been used for development of piece of web pages that <em>manage</em> information.</p><ul><li>Why called them <em>widgets</em>?</li></ul><p>Cause, after all, <em>widgets</em> actually are made to show information, so it’s seems logical to call them that way.</p><h3>Examples</h3><p>There should not be one motivation for use a name proposal without an example, and that’s what I’m going to give you.</p><pre>import { Component, Input } from &#39;@angular/core&#39;;<br>import { ITodoItem } from &#39;./../../models&#39;;</pre><pre>@Component({<br>  selector: &#39;my-todo-list-widget&#39;,<br>  template: `<br>  &lt;ul&gt;<br>    &lt;my-todo *ngFor=&quot;let todo of todoList; trackBy:todo?.id&quot; [todo]=&quot;todo&quot; &gt;&lt;/my-todo&gt;<br>  &lt;/ul&gt; `,<br>})<br>export class TodoListWidget {<br>  @Input() public todoList: ITodoItem[];<br>}</pre><p>This is a simple case of use. I’ll try to explain the code.</p><pre>import { Component, Input } from &#39;@angular/core&#39;;<br>import { ITodoItem } from &#39;./../../models&#39;;</pre><p>First of all, imports. From @angular/core we import input and component decorators. Remember, everything in Angular it&#39;s a decorator, so are Widgets, that name it&#39;s just sugar. There is not a Widget decorator, and I don&#39;t think that it should be one. From a model folder, the import of the Item model.</p><pre>@Component({<br>  selector: &#39;my-todo-list-widget&#39;,<br>  template: ` &lt;ul&gt;<br>    &lt;my-todo *ngFor=&quot;let todo of todoList;trackBy:todo?.id&quot; [todo]=&quot;todo&quot; &gt;&lt;/my-todo&gt;<br>  &lt;/ul&gt; `,<br>})</pre><p>So we decorate. I use the suffix widget for the selector, cause I had a component with the same name. So if you can name things better than I do, you should not need that. Also, the template, the less, the better. I think that if your template it&#39;s less than 10 lines, you should inline it. But, it&#39;s up to you. What is important it&#39;s to define all the display behavior here.</p><pre>export class TodoListWidget {<br>  @Input() public todoList: ITodoItem[];<br>}</pre><p>Finally, we declare the class. This is the important part. As you can see, there is not logic here. It’s just a class requesting an input property and nothing else.</p><h4>More examples</h4><p>If you want a couple of more examples about Widgets, checkout my repo <a href="https://github.com/michaeljota/angular2-ultimate-starter">angular2-ultimate-starter</a>. This is based of AngularClass starter, but I added ngrx/store implementation, and a couple patters borrow from React, as Widgets.</p><h3>Thanks you</h3><p>This is all for now. This is my first post, like ever, about Angular. I hope you enjoy this, and for anything you have to say about this, I’m looking forward to read your comments. Cheers and happy coding!</p><p><em>Originally published at </em><a href="https://dev.to/michaeljota/widgets-and-components-for-angular-2-and-up"><em>dev.to</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=42b0bb28794c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>