Skip to content

Querying the state of the grid #10

Description

@grancalavera

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions