Skip to content

Dynamic handling of grid options, and document how to avoid watchers (ng-if, ng-class, ng-show etc) #1819

Open
@PaulL1

Description

@PaulL1

When I started on the project I was surprised at how much hand-rolled code there was - click event handlers and the like. I generally followed the pattern, but without understanding why. I now understand that it is a deliberate strategy to avoid the performance impacts of large numbers of watches being fired on every digest cycle.

What would be great is to create some documentation for new contributors on:
a) Why we do this
b) The common patterns - so if you would have used an ng-show, you should instead do a compile or an append in the specific circumstance you need
c) Common gotchas, so if we hand roll then we need to have handlers for the common triggers - if you are simulating an ng-class, then you need to recalculate it whenever the data changes

I also wonder whether we could add some helper methods, or registration functions, or something (or perhaps we already have these and they're the column builders etc which should be getting reused). My thought here is that once we write down the patterns, we'd suddenly see that we have a bunch of items that we'd like to reevaluate whenever the data changes. Ideally we'd have a single data watch / registration thing that holds a list of registered functions that should be called when it observes a data change (or even that gets called centrally by anything that changes data, such as the edit feature).

If we got this right, we could simplify this whole process into a standard set of registrations that people use to get the equivalent of an ng-show, an ng-if etc. Basically it'd be a helper function that took a template and a condition, and some information about what events require a reevaluation of the condition. It would be like a custom angular - so it still takes the load off the developer, but the triggers for reevaluation are much more tailored than just "every digest cycle re-evaluate the whole thing".

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions