github.com/brunolm/react-how-to is a repository that shows how to do things by example.
Each Pull Request on this repository is a complete guide on how to do something, for example if you want to add
redux to your project you can just check this Pull Request and see some instructions and all changes required.
If you want to setup tests check this Pull Request.
Better than just reading some instructions you get a full example and a working project as a guide.
I found a challenge called “The Bomberman Game” on HackerRank and I found it pretty interesting.
It boils down to something like this:
The Bomberman Game
- Bombs will explode in 3 seconds
- When a bomb explodes it clears its tile and 1 tile up, down, left, right
- Bombs that are about to go off explode at the same time
- There are no chain reactions
- If a bomb explodes next to another that is not about to go off then the nearby bomb is just cleared
- Bomberman plants some bombs (you’re given an input with the map)
- A second passes
- A second passes. Bomberman plants bombs on all empty slots
- A second passes
- Repeat 3 and 4 until N seconds passes
R = number of rows
C = number of cols
S = number of seconds
O = bomb
. = empty
R C S
Return the map after N seconds have passed.
The first thing I though was to solve it with a generator (well, there was no real need to use it, but since it is about a game I thought it would be fun to be able to access any state of the game).
@angular/cli is a package that allows you to create/run/test/build an Angular application.
You can install it globally
npm i -g @angular/cli
If you run the cli commands in a project that also has the cli installed it will use the project cli version instead.
For the latest version always check brunolm/Docs/blob/master/code/js-ts/style.md.
The style and guides used here is how I code. Different people/companies might use different styles.
In redux there are actions and reducers.
An action executes some code and sends data to a reducer to update the application state. The application tends to get a bit messy the more actions and reducers you have.
To solve this problem I created this architecture
You can find the bot project on my Github – slack-genos.
There is a node package called slack that extracts all the Slack API and create functions for each.
npm i -S slack
They don’t provide TypeScript definition files, but we can create on own file under
With that I created a structure to run the bot.
ts-node is a package that allows you to run TypeScript (
.ts) files without a build step.
You can run a TypeScript project with:
Imagine a large scale application, with a big database full of tables and columns. Now imagine that you will have to remove a column from one of the tables, how would you guarantee that removing that column will not cause issues on your application?
await knex('student').where('deleted', false);
await are keywords commonly used on C#. They allow you to perform async operations without the callback hell.
The “callback hell” happens when you perform multiple async operations. For each operation you need to send a callback, a function that will execute when the operation completes.
- How do I install?
- Does it work on Linux/Mac?
- Does my editor support it?
- Do I have to learn a whole new language? Like CoffeeScript, Dart…?
- Any big companies using it?
- Does it support React?
- Have you ever coded a real project with it?
- Yes and I actually kept it compatible with the architecture of other (js) projects in my company. One of the projects is scaling.
- How many bugs did you prevent?
- Over 9000… A lot and very recently I found a bug in production in a very big project that would never happen if it was coded in TypeScript.
- Do you still use babel?
- Not if I get to choose which version of node I will be using. For some old versions some polyfills are really good… TypeScript does not add polyfills, it does not change your code more than enough to support a few ES features. You can check it out for yourself on TypeScript playground, the playground targets ES3, so if you use arrow functions or async/await TypeScript will “alter” your code.