Skip to content

Instantly share code, notes, and snippets.

@wejrowski
Last active September 16, 2016 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wejrowski/020a093aeccd95ec5ee11262a883bb90 to your computer and use it in GitHub Desktop.
Save wejrowski/020a093aeccd95ec5ee11262a883bb90 to your computer and use it in GitHub Desktop.
Declarative data loading in Polymer

Declarative data loading in Polymer

  • Rather than writing a lot of imperative code how can we write more straightforward/simpler/consistent code, less prone to bugs.

Nextgen data loading components

  • Spawned off with needing to solve binding and data store issues when updgrading to Polymer 1.
    • Polymer 0.x used the Object observe to update bindings. We referenced a global store using basically an Object.assign function that updated elements referencing those objects.
    • Came up with an inf-store-observer component to listen for and bind updates
    • Working with this more and through this refactor I noticed a couple ways we could simplify data loading and binding
      • Make data loading consistent & straightforward
      • Reduce complexity/indirection of global data store binding

The Problems

  • Use declarative data componets to hide implementation details & bind data to templates
  • Make simple composable components rather than one component that does everything
  • Simple way to setup new polymer data components for a model or model list (specific to our backend responses)
  • Easy way to keep model or lists in sync & binding updated

The Refactors:

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