Skip to content

immediate selectorGraph() change logging #17

@MattCowski

Description

@MattCowski

Currently, changes in state will not immediately be reflected in reselect-tools unless selectorGraph() is fired (i.e. on clicking "refresh" in the extension). I've overcome this by adding some redux middleware:

const reselectTools = store => next => action =>{

  const nodes = selectorGraph().nodes

  let result = next(action)
  
  if (typeof action === "function") return result

  const nextNodes = selectorGraph().nodes

  const nnKeys = Object.keys(nextNodes) // ["data$", "ui$"]

  // log if action changed any selectors
  nnKeys.forEach(k=>{
    if (nextNodes[k].recomputations!= nodes[k].recomputations) console.log({
      ...checkSelector(k), action
    })

  })

  return result

}

image

Now I can at least search in the console for a selector and see the action that triggered it whenever it's recomputed. It'd be great to combine this with the extension search filter.
It seems like this should be the default, or maybe there is a better way to do this? Also, any way to remotely update the extension?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions