Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

immediate selectorGraph() change logging #17

Open
MattCowski opened this issue Apr 17, 2019 · 1 comment
Open

immediate selectorGraph() change logging #17

MattCowski opened this issue Apr 17, 2019 · 1 comment
Labels

Comments

@MattCowski
Copy link

MattCowski commented Apr 17, 2019

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?

@skortchmark9
Copy link
Owner

Hey Matt - your solution looks good to me! Technically this library does not depend on redux, so I'd be reluctant to add any kind of redux-specific middleware. However, this looks like a simple recipe for getting the desired behavior.

I'm not sure I understand your question about 'remotely updating the extension'. Could you clarify?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants