v1 Online Demo: https://codesandbox.io/s/v1-angular-numeric-ljwlb
v2 Online Demo: https://codesandbox.io/s/v2-angular-numeric-3w2wr
import { Component } from '@angular/core' | |
@Component({ | |
selector: 'i18n', | |
moduleId: module.id, | |
template: `<span i18n="@@foobar">Hello {{placeholder}}!</span>` | |
}) | |
export class I18NComponent { | |
placeholder: any | |
} |
import * as React from 'react'; | |
export function getLocalStorageItem<T>(key: string, ifNull: T) { | |
try { | |
var item = localStorage.getItem(key); | |
return item === null ? ifNull : JSON.parse(item); | |
} catch (e) { | |
localStorage.removeItem(key); | |
return ifNull; | |
} | |
} |
v1 Online Demo: https://codesandbox.io/s/v1-angular-numeric-ljwlb
v2 Online Demo: https://codesandbox.io/s/v2-angular-numeric-3w2wr
This recipe is useful for cooking up chained API calls as a result of a single action.
In the below example, a single action called POST_REPO
is dispatched and it's intention is to create a new repostiory on GitHub then update the README with new data after it is created.
For this to happen there are 4 API calls necessary to the GitHub API:
Facades are a programming pattern in which a simpler public interface is provided to mask a composition of internal, more-complex, component usages.
When writing a lot of NgRx code - as many enterprises do - developers quickly accumulate large collections of actions and selectors classes. These classes are used to dispatch and query [respectively] the NgRx Store.
Using a Facade - to wrap and blackbox NgRx - simplifies accessing and modifying your NgRx state by masking internal all interactions with the Store
, actions
, reducers
, selectors
, and effects
.
For more introduction, see Better State Management with Ngrx Facades
Uncle Bob, the well known author of Clean Code, is coming back to us with a new book called Clean Architecture which wants to take a larger view on how to create software.
Even if Clean Code is one of the major book around OOP and code design (mainly by presenting the SOLID principles), I was not totally impressed by the book.
Clean Architecture leaves me with the same feeling, even if it's pushing the development world to do better, has some good stories and present robust principles to build software.
The book is build around 34 chapters organised in chapters.
These rules are adopted from the Angular commit conventions.
ATTENTION!
I keep this Gist for archival reasons, however I strongly recommend against using it. As I discovered after several weeks in production usage, these BEM mixins cause unexpected, unfixable and hard-to-debug selectors in some cases (especially when nested in some ways).
This is a utility with three simple Sass mixins for writing BEM as DRY as possible, heavily inspired by Hugo Giraudel's article on CSS Tricks.
It exposes three Sass mixins: block
, element
and modifier
.
... Typed with TypeScript
... With Testing Mock-up
GitHub - Done (for now)
- Filename used: ./src/utilities/functions.ts
// MIT Licensed | |
// Author: jwilson8767 | |
/** | |
* Waits for an element satisfying selector to exist, then resolves promise with the element. | |
* Useful for resolving race conditions. | |
* | |
* @param selector | |
* @returns {Promise} | |
*/ |