-
Notifications
You must be signed in to change notification settings - Fork 3
Callbacks
tobiasz.cudnik edited this page Sep 22, 2008
·
22 revisions
Callbacks are functions _called back_ by other functions in proper moment (eg on Ajax request error).
In *JavaScript* this pattern can be very flexible due to Closures support, which can be inline (no code break) and inherits scope (no need to passing params).
- PHP* has simple support for callback and here case is more complicated. That's why *ParamStructures* has been introduced in phpQuery. ParamStructures are just list of params, that can be your's or defined places for callback's ones. Example:
* `phpQuery::each()` * `phpQuery::map()` * `pq()->each()` * `pq()->each()`
There's also easy way to including scope, which means just variables accessible in specified point of code. It's achieved using compact() and extract() functions. Look at this modified example:
In the future this functionality will be developed.