Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow dynamic component control registration #4

Closed
wants to merge 2 commits into from

Conversation

wombleton
Copy link

Expose registering components so that they can be registered after view initialisation.

@johnyanarella
Copy link
Member

Good idea. I think this would work well, paired with another public method for unregistering dynamically added components. I will review this with the team.

@ghost ghost assigned johnyanarella May 7, 2012
@johnyanarella
Copy link
Member

We're considering some options for how we can solve this issue and #5 such that the framework automatically handles the complexity of these common concerns for the developer.

Even so, I suspect we'll still want to expose public methods like you proposed to support less conventional use cases and manual optimization.

@johnyanarella
Copy link
Member

In addition to the new live component selector syntax available in the Deft.mvc.ViewController's control annotation, I have also introduced the following new public methods to allow manual access to the same functionality:

Deft.mvc.ViewController::addComponentReference( id, selector, live = false )
Deft.mvc.ViewController::removeComponentReference( id )
Deft.mvc.ViewController::addComponentSelector( selector, listeners, live = false )
Deft.mvc.ViewController::removeComponentSelector( selector, live = false )
Deft.mvc.ViewController::getComponentSelector( selector )

Deft.mvc.ComponentSelector::addListener( eventName, fn, scope, options )
Deft.mvc.ComponentSelector::removeListener( eventName, fn, scope )

References, selectors and listeners are automatically cleaned up when the view (and consequently the ViewController) is destroyed.

This new feature is available in the code currently in the master branch and will be shipped as part of Deft JS v0.8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants