pvncad. Thanks for the pointer. If anyone else has this issue here is
what the source code of one of the async functions used in the preview
looks like. The key is to listen for "preview-change" and be able to
do the right set of add and remove event handlers.
function askResolveEntry( onComplete, pblock )
{
var aborted = false;
// In preview mode, we need to be causious and listen for changes to
abort the resolution
if( pblock != null )
{
function onPreviewChange()
{
pblock.removeEventListener( "preview-change",
onPreviewChange,
false );
aborted = true;
}
pblock.addEventListener( "preview-change", onPreviewChange,
false );
}
if( pblock )
pblock.innerHTML = "Correlating page to an RSS article. Please
wait...";
var reader = StreetsUtils.lookupCore().service( "reader" );
reader.askResolveEntryId( getRSSContext(),
function(
entryId )
{
if(
aborted == true )
return;
if(
pblock != null )
pblock.removeEventListener( "preview-change",
onPreviewChange, false );
if(
entryId == null && pblock != null )
{
if( pblock != null )
pblock.innerHTML = "This page does not map to an RSS
article";
else
displayMessage( "This page does not map to an RSS
article" );
}
onComplete( entryId == null ? null : reader.lookupEntry
( entryId ) );
}
);
}
On Jan 13, 7:51 am, pvncad <[email protected]> wrote:
> Using CmdUtils.previewGet() will do the trick for you.
>
> On Jan 13, 5:35 pm, Edwin Khodabakchian
>
> <[email protected]> wrote:
> > Hello,
> > I am writing a command whose preview has an asynchronous dependency
> > and I was wondering if there is a way to know on the callback if the
> > command is still previewed or if the user has moved on and the command
> > is no longer previewed. Is there a state variable on the command which
> > would allow me to know?
> > Thank you,
> > Edwin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"ubiquity-firefox" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/ubiquity-firefox?hl=en
-~----------~----~----~----~------~----~------~--~---