After writing my previous blog post, I tested require.js and found that requiring the same file multiple times does in fact give you the same instance. Since this is the case, I no longer need to pass the storage manager into functions returned to construct disp_note_ui and notes_ui_manager. Since these functions now take no arguments, they don't need to be functions at all, and the objects can be returned directly. I removed the _init suffix from these js files.
For example, in generate_notes_view.js, instead of
notes_storage_mgr
being defined by being passed into
this function, it is just
passed in by require.js here.
I did this in
a new branch; I'm going to hold off on merging this to master until I talk to Kevin. Personally, I think it's an improvement, but I'd like to get another opinion first.
No comments:
Post a Comment