Question

There is a new MVC mechanism built in Enyo 2.3pre but there is absolutely now docs on it.

The question is how can I bind specific controller to my view?

I have a new kind based on enyo.Control e.g. and I have a controller based on kind: 'enyo.ViewController',

In my controller I have handlers object with a function that should handle event.

If I put view prop into controller with a name of my view that doesn't work since my handler in controller is not invoked

Can you post some examples on this?

Was it helpful?

Solution

So, the enyo.ViewController, by default, wants to renderInto document.body and we use it to define the enyo.Application kind as the "starting point" for your application.

The Enyo implementation is not necessarily "pure" MVC in the sense that you don't necessarily have to have a proper controller for every view (or enyo.Control) that you are dealing with. Enyo has always had a sort of hybrid view/controller system baked into the controls themselves.

With that being said, recent changes to the implementation removed bubbling of events to a "controller" that owned your "view" as it resulted in a lot of unnecessary overhead. In fact, we're removing the "controllers" block from the enyo.Application kind as an app-global reference to various controllers, and instead you will place them in a components block as typical of "traditional" Enyo development.

So, the current thinking is that your view will handle events as before, but you can bind to properties of various "controllers" and models.

Now, you can still create an MVC architecture if you really want to, but the system is flexible enough to support any of the "separation of concerns" methodologies (MVC, MVP, MVVM, etc.)

My current way of going about things is to create a "controller" for doing some things (like make Web service requests) and then build out models from the data I get back, add them to a collection, and then my views probably have a data-aware control (such as enyo.DataRepeater or enyo.DataList) that will automatically generate some rows for each model.

Take a look at this simple example: http://github.com/clinuz/college-football but, be advised it may not be up-to-date with the switch from app-wide controllers to components. And also, we're removing the "controller" property of the DataRepeater/List and it will change to "collection."

Let me know if you need some more hints. We're aware the lack of documentation is making this difficult while we finalize our implementation. Please bear with us!

OTHER TIPS

You could see my example of to checkout enyo MVC structure. https://github.com/prajnavantha/enyo-internetradio

Basically we have a model, view and controller. models: In my case is a simple enyo.Model kind. U can have enyo.collections etc... Controller: i've used enyo.ModelController. Views: have the kinds:

The application is not totally MVC. Since my logic is still in views. However you can understand, how to set model and use the componenets.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top