background image
C H A P T E R 1 1
Data Storage and Retrieval
11-64
Using Newton Data Storage Objects
control how and when notifications are sent
The first part of this section describes how to register and unregister a callback
function for execution in response to changes in a particular soup. The next part
describes the various notifications that may be sent. The last part of this section
describes how applications send soup change notifications.
Registering Your Application for Change Notification
11
The
RegSoupChange
global function registers a callback function for execution
in response to changes in a particular soup. Note that this callback function must
not call either of the
RegSoupChange
or
UnRegSoupChange
functions.
If your application needs to respond to changes in more than one soup, you'll need
to call the
RegSoupChange
function once on each soup for which your
application requires change notification. This approach is valid for any system-
supplied soup except that used by the built-in Preferences application. For
notification of changes to user preferences, you must call the
RegUserConfigChange
function.
You can call the
RegSoupChange
function at any time that makes sense for your
application. For example, you might do so from within your base view's
viewSetupDoneScript
method; however, this is only a suggested guideline. In
order to conserve available memory, your application should minimize the amount
of time callback functions remain registered.
The following code example shows how to register your application for notification
of changes to the soup used by the built-in Names application:
local myFn := func (soupName, appSym, changeType, changeData)
begin
if (changeType) then
begin
if (changeType <> 'whatThe) then
print (changeType && "in the" && soupName &&
"soup by the" && GetAppName(appSym) &&
"application.");
else
print ("Unspecified changes occurred in the" &&
soupName && "soup.");
end;
end;
// register for changes to soup used by built-in "Names" app
RegSoupChange(ROM_CardFileSoupName, '|myFn1:MyApp:MySig|, myFn);
© 2007-2024, o7 studio » при воспроизведении материала сайта ссылка обязательна