1.2 beta feature - Filter Enhancements

0 views
Skip to first unread message

chris thatcher

unread,
Aug 27, 2010, 12:06:09 PM8/27/10
to jquery-...@googlegroups.com
Filters are now all provided two additional pieces of information.  These are 'target' and 'method'. Each type of filter needs to provide these in a different way to ensure backward api compatibility but its pretty easy to demonstrate each.

$.filters([{
        id        : "#exampleBeforeFilter",
        target    : "MyApp.Controllers.*",
        before    : "([a-z]*)",
        advice    : function(event){
var advisee = arguments[arguments.length - 1];
            log.debug('Adding normalized event state to event scoped model %s.%s',
advisee.target, advisee.method);
            var params = event.params('parameters');
            
            event.
                m({admin:('admin' in params)?true:false }).
                m(event.params());
        }
    }

--
Christopher Thatcher

chris thatcher

unread,
Aug 27, 2010, 12:06:50 PM8/27/10
to jquery-...@googlegroups.com
Sorry that was an accidental send...  Lets try that again
--
Christopher Thatcher

chris thatcher

unread,
Aug 27, 2010, 12:20:14 PM8/27/10
to jquery-...@googlegroups.com
Filters are now all provided two additional pieces of information.  These are 'target' and 'method'. Each type of filter needs to provide these in a different way to ensure backward api compatibility but its pretty easy to demonstrate each.

$.filters([{
     id        : "#exampleBeforeFilter",
     target    : "MyApp.Controllers.*",
     before    : "([a-z]*)",
     advice    : function(){
//the details are tacked on as an extra argument
var advisee = arguments[arguments.length - 1];

        log.debug('Before %s.%s', advisee.target, advisee.method);
//logs "Before MyApp.Controllers.Foo.doit"

     }
},{
    id        : "#exampleAroundFilter",
    target    : "MyApp.Views.*",
    around    : "(.*)",
    advice    : function(invocation){
        log.debug('Around %s.%s', invocation.target, invocation.method);
//logs "Around MyApp.Views.Foo.renderit"
       
    }
},{

id        : "#exampleAfterFilter",
target    : "MyApp.Models.*",
around    : "(.*)",
advice    : function(returnValue, target, method){
          log.debug('After %s.%s', target, method);
     //logs "After MyApp.Models.Bar.getit"
}
}]);
--
Christopher Thatcher

Jrad

unread,
Aug 28, 2010, 3:07:37 AM8/28/10
to jquery-claypool
Thats nice Chris :)

On Aug 27, 7:20 pm, chris thatcher <thatcher.christop...@gmail.com>
wrote:
> Filters are now all provided two additional pieces of information.  These
> are 'target' and 'method'. Each type of filter needs to provide these in a
> different way to ensure backward api compatibility but its pretty easy to
> demonstrate each.
>
> $.filters([{
>      id        : "#exampleBeforeFilter",
>      target    : "MyApp.Controllers.*",
>      before    : "([a-z]*)",

Jrad

unread,
Aug 28, 2010, 4:19:52 AM8/28/10
to jquery-claypool
Is this feature available in 1.2rc? I've downloaded the js file but
got no success!
Reply all
Reply to author
Forward
0 new messages