Skip to content

Instantly share code, notes, and snippets.

View steveholgado's full-sized avatar

Steve Holgado steveholgado

View GitHub Profile
@steveholgado
steveholgado / - array-functions.md
Last active January 16, 2019 20:14
Useful functions for working with arrays

Array functions

Useful functions for working with arrays:

  • Range
  • Flatten (recursively)
  • Chunk
  • Remove duplicates
  • Remove duplicates by object property
  • Group by object property
@steveholgado
steveholgado / - vuejs-sass-environment-variables.md
Created January 16, 2019 20:25
Make environment variables available as Sass variables in Vue.js

Vue.js: Environment variables in Sass

Make environment variables available as Sass variables in Vue.js.

@steveholgado
steveholgado / - toy-observables-library.md
Last active December 19, 2019 22:23
A toy observables library inspired by RxJS, with pipeable operators.

React useObservable hook

A hook for integrating RxJS observables with React.

Example usage

const [value, next, error, complete] = useObservable(obs$ => obs$.pipe( /* ... */ ), 'initial value')

React useMostRecentFetch hook

A hook for fetching data where only the response from the most recent fetch request is needed.

When the arguments are updated, a new fetch request is triggered and the previous one is aborted and ignored.

This is useful in situations where a user might make selections in the UI that trigger multiple fetch requests. For example, selecting from a group of filters which then fetches new data from an API. In this situation, only the most recent selection is relevant.

Example usage