I'm starting with Polymer, 2.0, and I have a design question that I cannot find an answer to, and I hope you can help me.
The point is that I'm working on a Task Manager system that consumes an external api (laravel in this case) to start/stop a task, edit or create a new one, etc.
What I'm not able to find is the best approach to handle the business specific logic, because as far as I know the Polymer Elements should be reusable and including the api calls and other funtionality into the Polymer Element doesn't seem to be the best solution, although it's the easiest.
I have several alternatives in mind: - Manage everything using custom events from a top level JS class that make the api calls and update the Polymer Elements. - Use mixins to extend from Polymer Element and a custom Task class containing the needed methods/logic. - pass to the Polymer Element a Task object and save it as a property and call the method through it.
Could anybody tell me which is the best approach? Although I'm sure that is not going to be any of the three I said :)
Thank you!
Aucun commentaire:
Enregistrer un commentaire