question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Polymer 2 demo? (and Polymer 3?)

See original GitHub issue

Hi @tur-nr

Thanks so much for the very interesting library. I’m writing my very first open source Polymer + Redux app that will be going to production in Kenya on thousands of tablets in schools and it’s very timely that @tjsavage mentioned this library in his Chrome Dev Summit talk.

I did pass by this library when I was doing my original research but being so green I had a hard time understanding how the pieces fit together. After finding an example of how to use Redux in Vanilla JS, I realized that part was dead simple and then had to figure out how to pass state up with some standards around emitting events and attaching payload to event.details and then started using Object.apply(element, state) to properties that have reflectToAttribute: true.

Everything seems to be work fine and dandy but I’m still interested in the ways that this library can help reduce boilerplate. Is the key proposition of this library the following example at https://tur-nr.github.io/polymer-redux/docs?

class DemoApp extends ReduxMixin(Polymer.Element) {
  // ...

  static get properties() {
    return {
      message: {
        type: String,
        statePath: 'message' // Binds state, "Hello, World!"
      }
    };
  }
}

If I understand correctly this saves us from writing the boilerplate of…

  1. You don’t have to write boilerplate of subscribing a component to the store because it’s passed in via ... extends ReduxMixin(Polymer.Element).
  2. You don’t have to write the boilerplate of applying state to element attributes/properties because element properties are binded to location in the store via statePath: 'message' in the element properties declaration.

Basics aside, I’d love to see the demo code for this updated to Polymer 2 and the impeding Polymer 3 release. Potentially, the demo could actually be the HN Polymer example. I mentioned this in that in the HN Polymer issue queue https://github.com/Polymer/hn-polymer-2/issues/14.

Lastly, for the newbies like myself, perhaps a demo using Redux without polymer-redux so we can compare and contrast? That could help for folks like me who are still groking Redux and Web Components to jump to using Redux, Polymer, and Polymer-Redux.

Thanks again!

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

15reactions
tur-nrcommented, Oct 30, 2017

I think you must have an understanding of the Flux/Redux paradigm first. One mistake with using this library is that majority of the issues/questions are about the redux or confusion with unidirectional data flow Polymer elements must adapt to.

The aim of this library was to create the applications store outside of any Polymer specific code. Then using the Mixin you can bind state to the components that need it. Typically many applications create a redux-mixin.html file with the store boilerplate in there but I think it’s a lot cleaner if you just include the store for the Mixin creation.

One thing to note is @kevinpschaaf approach will be adopted with Polymer 3 with Polymer 2 compatibility. Read more here: https://gist.github.com/kevinpschaaf/995c9d1fd0f58fe021b174c4238b38c3 and see #110 PR.

I will work on a boilerplate application in the mean time.

  • Scaffold an empty Polymer+Redux project.
  • Create a simple todo using above template.
1reaction
yanmagalecommented, Oct 30, 2017

@rjsteinert i’m using this project with in My Calm App, wrote in Polymer 2 - and other small projects

I agree with you that it is very important to show a both versios into website. If a person not known flux architecture and its implementations (as redux), it is very complex this first contact

Read more comments on GitHub >

github_iconTop Results From Across the Web

Polymer library - Polymer Project
The Polymer library provides a set of features for creating custom elements. ... If you're upgrading an existing 2.x element to 3.x, see...
Read more >
What's new in 2.0 - Polymer Project
Polymer 2.0 is designed to support the new custom elements v1 and shadow DOM v1 specifications being implemented by most major browser vendors, ......
Read more >
Step 1: Get set up - Polymer library
The demo shows three icon-toggle elements, two. If everything looks good, move on to step 2. Step 2: Add local DOM.
Read more >
Step 1: Set up - Polymer Project
The demo shows three icon-toggle elements, two. Keep the demo open, and move on to step 2. Step 2: Add local DOM.
Read more >
Case study: the Shop app - Polymer Project
You're viewing an older version of the Polymer library documentation. ... Shop is a full-featured e-commerce Progressive Web App demo built using the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found