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

Querying the state of the grid #10

Open
grancalavera opened this issue Oct 19, 2016 · 0 comments
Open

Querying the state of the grid #10

grancalavera opened this issue Oct 19, 2016 · 0 comments
Labels

Comments

@grancalavera
Copy link
Contributor

grancalavera commented Oct 19, 2016

We have some use cases where we need to interrogate the grid for its internal state. At the moment we are using a solution that looks like this:

import { createSnapshotHook, createHook } from 'grid-hook-component'

const hook =  createHook(callback)

function callback(rows, columns) {
  // some side effect
}

myGrid.use( createSnapshotHook().hook(hook) )

Then further down in our application we can request a snapshot at any time, and it will be handled by the hook's callback:

hook.requestSnapshot()

In #7 we discussed this might make more sense to do at the grid level. Is that the case? I think it might be a good idea to implement it as a component. I can see at least 2 use cases for a hook component:

  1. You can define many different hooks and pass them to the grid to query the state at different times
  2. You can define a single hook and process in many different ways (ala middleware) by several consumer.

Thoughts?

@grancalavera grancalavera changed the title Investigating the state Querying the state of the grid Oct 19, 2016
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

1 participant