You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rave.apache.org by Chris Geer <ch...@cxtsoftware.com> on 2013/08/27 23:54:34 UTC
Overloading JS functions using Require
How would I go about replacing a JS function from Rave with my own
implementation using the new require approach? I don't want to have to
overwrite the whole file if possible.
Chris
Re: Overloading JS functions using Require
Posted by Erin Noe-Payne <er...@gmail.com>.
Yep that should do it, and then make sure that this override module is
included in your dependency tree.
On Wed, Aug 28, 2013 at 2:47 PM, Chris Geer <ch...@cxtsoftware.com> wrote:
> Ok, so I actually want to overload the getSecurityToken method in the
> rave_api.js. So would it look like this?
>
> define(['core/rave_api'], function (api) {
> api.restApi.getSecurityToken = function(){
> console.log('heyoooooo');
> }
> });
>
> Since that js file returns two objects instead of one?
>
> Chris
>
>
> On Wed, Aug 28, 2013 at 11:04 AM, Erin Noe-Payne
> <er...@gmail.com>wrote:
>
>> Each module should be resolved only once, so you can write a new
>> module that requires in the core module and then overrides the
>> function you want. As an example, say I wanted to change the way rave
>> core's registerWidget function works....
>>
>> define(['core/rave_widget_manager'], function (widgetManager) {
>> widgetManager.registerWidget = function(){
>> console.log('heyoooooo');
>> }
>> });
>>
>> I have now overridden the function with my new implementation.
>>
>> On Tue, Aug 27, 2013 at 5:54 PM, Chris Geer <ch...@cxtsoftware.com> wrote:
>> > How would I go about replacing a JS function from Rave with my own
>> > implementation using the new require approach? I don't want to have to
>> > overwrite the whole file if possible.
>> >
>> > Chris
>>
Re: Overloading JS functions using Require
Posted by Chris Geer <ch...@cxtsoftware.com>.
Ok, so I actually want to overload the getSecurityToken method in the
rave_api.js. So would it look like this?
define(['core/rave_api'], function (api) {
api.restApi.getSecurityToken = function(){
console.log('heyoooooo');
}
});
Since that js file returns two objects instead of one?
Chris
On Wed, Aug 28, 2013 at 11:04 AM, Erin Noe-Payne
<er...@gmail.com>wrote:
> Each module should be resolved only once, so you can write a new
> module that requires in the core module and then overrides the
> function you want. As an example, say I wanted to change the way rave
> core's registerWidget function works....
>
> define(['core/rave_widget_manager'], function (widgetManager) {
> widgetManager.registerWidget = function(){
> console.log('heyoooooo');
> }
> });
>
> I have now overridden the function with my new implementation.
>
> On Tue, Aug 27, 2013 at 5:54 PM, Chris Geer <ch...@cxtsoftware.com> wrote:
> > How would I go about replacing a JS function from Rave with my own
> > implementation using the new require approach? I don't want to have to
> > overwrite the whole file if possible.
> >
> > Chris
>
Re: Overloading JS functions using Require
Posted by Erin Noe-Payne <er...@gmail.com>.
Each module should be resolved only once, so you can write a new
module that requires in the core module and then overrides the
function you want. As an example, say I wanted to change the way rave
core's registerWidget function works....
define(['core/rave_widget_manager'], function (widgetManager) {
widgetManager.registerWidget = function(){
console.log('heyoooooo');
}
});
I have now overridden the function with my new implementation.
On Tue, Aug 27, 2013 at 5:54 PM, Chris Geer <ch...@cxtsoftware.com> wrote:
> How would I go about replacing a JS function from Rave with my own
> implementation using the new require approach? I don't want to have to
> overwrite the whole file if possible.
>
> Chris