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

ViewController companions #130

Open
brian428 opened this issue Jan 29, 2014 · 4 comments
Open

ViewController companions #130

brian428 opened this issue Jan 29, 2014 · 4 comments

Comments

@brian428
Copy link
Member

Allow view controllers to share behavior with other view controllers.

@ghost ghost assigned brian428 Jan 29, 2014
@texastoland
Copy link

This looks implemented in DeftJS5?

@brian428
Copy link
Member Author

The logic I was building for Deft 0.9.x is there in the Deft 5 code, but I don't think it's going to work due to the way Ext 5 locates event listeners. Listeners are located by finding the "nearest" referenceHolder for the component (which would typically be the ViewController). That means additional handlers defined on the companion VCs would never be fired. I don't think there's a way around this without some serious mucking around with the underlying Ext 5 event system.

@texastoland
Copy link

I noticed your implementation trying to understand how Deft integrates with the new Ext VCs. Was the idea that each controller would handle a behavior—like an EmailInputController to apply uniform validation logic across more complicated views? I built PureMVC and RL extensions like that a few years ago that were very useful. I thought I saw an old PR for accepting multiple VCs though. How would companions differ?

@brian428
Copy link
Member Author

The way I had it working in my 0.9.x feature branch was that you could basically associate additional view controllers with the "primary" view controller for a view. So additional logic and view event listeners could be attached, allowing common/cross-cutting logic to be shared. Since they remain encapsulated as separate view controllers, there was no danger of method names or anything else conflicting. It also meant that any view controller could act as either a primary VC or be attached as a companion VC.

It was actually a pretty cool design if I do say so myself. ;-)

Unfortunately, as I said, with the change to how listeners are handled in Ext 5, I think the whole idea has to be jettisoned. When we were actually setting up listeners on the view to trigger VC handler methods, this was fine. Now that Ext 5 uses event handlers that are located at the time the event fires by looking only for the first reference holder, I don't see any way to get event handler methods defined in the companion VCs to be invoked. :-/

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

No branches or pull requests

2 participants