shiffman / BodyBlock

Experimenting with BodyPix model and Obscuring faces/bodies.
30 stars 4 forks source link

[State mgmt] Vanilla MVC setup #27

Open joeyklee opened 4 years ago

joeyklee commented 4 years ago

Description

This PR uses the vanilla JS approach outlined here (https://github.com/taniarascia/mvc/blob/master/script.js) to building a Model-View-Controller framework to help manage state and view updates.

This is currently a draft that is meant to highlight some of the challenges and opportunities of creating reactive UI from scratch. My current feeling is that while yes, it is nice to do this in a really plain JS way, it relies a lot on us to take care of sticking to the "rules" we create as opposed to following established ones by way of using a framework like react and vue.

I want to try and get this this demo to a working state so we can at least have a better feeling for what this approach entails, but I may also start a parallel thread and set up a version running on React using the contextApi to help us to resolve state sharing across components...and if that last bit sounds totally crazy, I will make sure to clarify that in the relevant PR :)

Updates

This PR is ready for review.

Screen Shot 2020-06-13 at 2 03 59 PM

Some of the previous styles have been dropped for now, but all of the pieces are now in place.

Setup explained

We have 4 main files:

Feedback

TBH, there's a lot of mental gymnastics involved with separating out the concerns. And as you'll see it's pretty verbose with all the updateX and bindHandlerY etc etc.

In any case, I think the structure does help us to separate out functionality in a cleaner way and would not be wasted time if we decide to move to using a framework.