In AppUnite, we enforce proper code style by:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="sidebar"> | |
<my-search-page-sidebar | |
[filters]="state.filters" | |
(filtersChange)="changeFilters($event)"> | |
</my-search-page-sidebar> | |
</div> | |
<div class="content"> | |
<h2>Search</h2> | |
<my-search-page-query-input | |
[value]="state.query" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// wrong (impure) | |
class DateTimePickerComponent { | |
timeZone: string = "Europe/Warsaw"; | |
constructor(private account: AccountService) { | |
if (this.account.currentUser) { | |
this.timeZone = this.account.currentUser.timeZone; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
flatten = array => { | |
return array.reduce((sum, x) => { | |
if (Array.isArray(x)) { | |
return [...sum, ...flatten(x)]; | |
} else { | |
return [...sum, x]; | |
} | |
}, []) | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable no-await-in-loop */ | |
/* eslint-disable no-restricted-syntax */ | |
// eslint-disable-next-line import/no-extraneous-dependencies | |
const puppeteer = require('puppeteer'); | |
const { green, red, cyan, grey, bold } = require('chalk'); | |
const url = 'http://localhost:9001/iframe.html'; | |
function runAxe() { | |
return new Promise((resolve, reject) => |
by Jacek Tomaszewski
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Action creator function | |
function fetchArticles(params = {}) { | |
return dispatch => { | |
dispatch({ type: 'FETCH_ARTICLES_START', params }); | |
ArticlesService.getArticles(params).then( | |
response => { | |
dispatch({ | |
type: 'FETCH_ARTICLES_SUCCESS', | |
data: response.data | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { call, put, takeLatest } from "redux-saga/effects"; | |
// Action creator function | |
function fetchArticles(params) { | |
return { type: FETCH_ARTICLES, params }; | |
} | |
// Sagas | |
function* fetchArticlesSaga() { | |
yield takeLatest(FETCH_ARTICLES, triggerFetchArticles); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Observable from 'rxjs/observable'; | |
// Action creator function | |
function fetchArticles(params) { | |
return { type: FETCH_ARTICLES, params }; | |
} | |
// Epic | |
const fetchArticlesEpic = action$ => { | |
return action$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fetch results when: | |
// - page is changed (immediately after): | |
// - "sort by" filter is changed (immediately after), | |
// - search query is changed (after 500 ms debounce), | |
// - filters are changed (after 300 ms debounce) | |
const refetchResultsEpic = action$ => { | |
return Observable.merge( | |
action$.ofType(CHANGE_QUERY).debounceTime(500), | |
action$.ofType(CHANGE_FILTERS).debounceTime(300), | |
action$.ofType(CHANGE_PAGE), |