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

Controller attributes are accessible only after a clean #52

Open
joaopmafra opened this issue May 11, 2015 · 4 comments
Open

Controller attributes are accessible only after a clean #52

joaopmafra opened this issue May 11, 2015 · 4 comments
Assignees
Labels

Comments

@joaopmafra
Copy link

Hi all,

If I define a controller like this

class CounterCtrl extends Controller { }

and run the application with ~fastOptJS, all attributes added to controller will only be accessible from within the view after I clean the application and run it again.
For example, if I start the application with ~fastOptJS and then add an attribute "foo" to the controller

class CounterCtrl extends Controller {
  var foo = "bar"
}

I need to stop the application, issue a clean, and start it again for the "foo" attribute be accessible within the view. The same thing doesn't happen with scope controllers.

Tested against angulate 0.2 and scalajs 0.6.2. I have a small project to demonstrate the issue: https://github.com/joaopmafra/scalajs-angulate-issues

Thanks in advance.

@jokade jokade added the bug label May 11, 2015
@jokade jokade self-assigned this May 11, 2015
@jokade
Copy link
Owner

jokade commented May 11, 2015

ControllerMacros.createController() is not called during compile after a property was added to, or removed from a Controller. Maybe a cache problem -> check with Scala.js list
This is caused by the way the actual Controller code is generated: code generation happens where module.controllerOf[] is called; if the class where this call occurs is unchanged, the macro won't be called (and hence the controller code is not re-generated).

@joaopmafra
Copy link
Author

Great! I tested with my codebase and it works the way you said. Thanks for investigating that.

Honestly, I would love to contribute to the project. But despite having 10 years of experience with java, I'm new to scala. I'm trying to learn the most important parts of the language for only then go to advanced features such macros. Thanks again.

@jokade
Copy link
Owner

jokade commented May 13, 2015

I've opened a thread on the scala-user list for this issue.

@jokade
Copy link
Owner

jokade commented May 24, 2015

This problem seems to be hard to solve with the current approach. We could use macro annotations on controller classes to generate the Angular.js code instead, which works quite well for angulate2. But that would mean to depend on macro paradise. Maybe we should provide annotations support in add-on library (or sbt plugin)?

@jokade jokade mentioned this issue Jun 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants