-
Notifications
You must be signed in to change notification settings - Fork 120
FAQ
If you wish to extend core Amber classes with extra methods, and commit those changes without overwriting the Kernel-Objects.js file (for example), you must set a "Method Protocol" for the method and enter the protocol of "*MyPackage" where "MyPackage" is the package you want to commit that method to. This is exactly like "class extensions" in Monticello in Pharo/Squeak etc and makes sure that the method belongs in the MyPackage package and not in the package of the extended class.
You have to use JQuery for doing that:
html p asJQuery html: '<p>hello world</p>'
Following the Seaside convention:
html p with: [ html a href: 'http://www.google.fr'; with: 'Google']
Events are fired and consumed in Amber via the "Announcements" system. To use announcements, first you need an instance of Announcer. There is already a SystemAnnouncer for example, which can be obtained through:
announcerInstance := SystemAnnouncer current.
You can also create your own single instance of Announcer or a subclass of it.
Then you need a class for each announcement (see SystemAnnouncement and subclasses).
Announcement classes don't necessarily need any methods.
Sending announcements is as easy as:
announcerInstance announce: AnnouncementClass new.
For receiving announcements you have to register a callback for the desired announcement class like the following:
announcerInstance on: AnnouncementClass do: [:announcement | "do something when announcement occurs"].
All Smalltalk instance variables can be accessed as JavaScript properties by adding an @ sign in front of their name. For example, to access the counter variable of class Counter you would do the following:
Counter>>assignTwo
< self[ "@counter" ] = 2; >
