Skip to content

Instantly share code, notes, and snippets.

Jack Tomaszewski jtomaszewski

Block or report user

Report or block jtomaszewski

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View a11y.md

Accessibility in Web

by Jacek Tomaszewski

Asana task

Accessibility

What is accessibility?

View redux-effects-example3.js
// When SUBMIT action happens:
// - emit VALIDATE action,
// - validate the form,
// - and when validating the form finishes with success:
// - emit SUBMIT_START action.
const validateOnSubmitEpic = (action$, state$) => {
return action$.ofType(SUBMIT).switchMap(() => {
const validate$ = Observable.of({ type: VALIDATE });
const onValidate$ = Observable.merge(
action$.ofType({ type: VALIDATE_SUCCESS }),
View redux-effects-example2.js
// 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),
View redux-effects-example.js
import Observable from 'rxjs/observable';
// Action creator function
function fetchArticles(params) {
return { type: FETCH_ARTICLES, params };
}
// Epic
const fetchArticlesEpic = action$ => {
return action$
View redux-saga-example.js
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);
View redux-thunk-example.js
// 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
});
@jtomaszewski
jtomaszewski / axe.js
Last active Mar 11, 2019 — forked from donaldpipowitch/axe.js
aXe based a11y checks in your CI for Storybook
View axe.js
/* 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) =>
View appunite-frontend-code-formatting.md

Code formatting & linting

In AppUnite, we enforce proper code style by:

  1. formatting of all our **/*.{js,jsx,ts,tsx,css,less,scss} files with prettier,

  2. linting all **/*.js files with ESLint,

  3. linting all **/*.ts files with TSLint.

@jtomaszewski
jtomaszewski / rt-stateful-component.ts
Created Jan 11, 2019
Example implementation of StatefulComponent in Angular
View rt-stateful-component.ts
// Code authored by [Recruitee](https://recruitee.com)
// License: MIT
import { Injectable, ChangeDetectorRef } from '@angular/core';
import { BehaviorSubject, Observable } from 'rxjs';
const immutableStateInvariantMiddleware = process.env.NODE_ENV !== 'production'
? require('redux-immutable-state-invariant').default
: null;
export interface RtStatefulComponent<State> {
View flatten.js
flatten = array => {
return array.reduce((sum, x) => {
if (Array.isArray(x)) {
return [...sum, ...flatten(x)];
} else {
return [...sum, x];
}
}, [])
};
You can’t perform that action at this time.