techwraith / ribcage-view Goto Github PK
View Code? Open in Web Editor NEWA simple base Backbone view class that adds subviews, rendering, and initialization.
License: MIT License
A simple base Backbone view class that adds subviews, rendering, and initialization.
License: MIT License
Hi!
The raf
module has introduced breaking changes in v1.0.0. The event emitter logic has been moved into raf-stream
, while raf
retains the actual polyfill logic.
Let me know if you need any help migrating.
What if we remade bindEvents
to have 1) a nicer API, and 2) auto-call stopListening
?
Here's my thought: we could copy the backbone events
object syntax:
, events: {
'click .mything': 'onMyThingClick'
}
, bbEvents: {
'change:key model': 'onModelChangeKey'
}
events
hash doesthis.
would be assumed. If omitted, it will listen on the view itselfbindEvents
would then become the method that parses this object. If over-ridden, (as we do now) things would behave as normal. Else, it just parses the bbEvents
object. That makes this backward-compatible.Adding lots of subviews is pretty slow, and could be optimized by using a documentFragment.
:)
Checkout the perf
branch.
Right now, we call it on every render, which is slow.
In the case that a model doesn't have an id
, falling back to the cid
(which is guaranteed to be there) would prevent breakage.
Here's a requirebin: http://requirebin.com/?gist=7127537
It looks like rendering a parent view clobbers the events on all the subviews.
This means that on every render, all my subviews have to be reinitialized, which is pretty expensive.
I'm not sure if this is a problem with the way i've structured my application or an actual bug in ribcage-view
. I feel like i should be able to render a parent view without wiping out all my subviews.
Currently, it's not possible to ensure that things we need to listen to are loaded before attempting to listen to them.
https://github.com/joeybaker/wheelhouse-view is a previous project that I worked on that has a lot of the same ideas of this project. Maybe steal some of them?
documentFragment
#7parent
property for subviews #24 โ rightly rejected by @techwraith b/c it's to tightly coupled. Just use events.model.toJSON
or collection.toJSON
if it's present https://github.com/joeybaker/wheelhouse-view/blob/master/view.js#L21-L25collectionChildren
to automate creating "collection views"?removeInner
method which allows the view to be destroyed by keep it's element in the DOM. Useful when the view is attached the main app container.#7 talks about using a document fragment to optimize sub-view rendering. An idea I've always had it to further optimize for a large number of subviews (> 50~ish?) and use requestAnimationFrame
to batch up the rendering so that the DOM doesn't lock up.
Would love some tests if possible :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.