Skip to content

Instantly share code, notes, and snippets.

View shazmodan's full-sized avatar

William Bergqvist shazmodan

  • Svea Bank
  • Stockholm, Sweden
  • 16:22 (UTC +02:00)
View GitHub Profile
@shazmodan
shazmodan / observeStore.md
Last active September 8, 2017 12:57
JavaScript Redux Observe Store Subscribe
export const observeStore = (store, select, onChange) => {
  let currentState

  function handleChange() {
    const nextState = select(store.getState())

    if (nextState !== currentState) {
      currentState = nextState
 onChange(currentState)