[Laszlo-dev] Fwd: [JIRA] Created: (LPP-4632) Dataset, doesn't send oninit event

Henry Minsky henry.minsky at gmail.com
Tue Sep 4 13:51:25 PDT 2007


I think that would work, I tried deferring the event send by making a
method to do it, and registering it on canvas init, and it behaves
properly:


function setData( data , headers ) {
...
...
...

    if (this.ondata.ready) {
        this.ondata.sendEvent( this );
    } else {
        new LzDelegate(this, "_sendOnData", canvas, "oninit" );
    }
}

/**
  * Sends an ondata event
  * @access private
  */
function _sendOnData () {
    this.ondata.sendEvent( this );
}


But I am not sure how to generalize this to other objects which have the
same issue with sending events to listeners who are not ready for them yet.





On 9/4/07, André Bargull <a.bargull at intensis.de> wrote:
> What about waiting for canvas-"oninit" before sending the "ondata"-Event
> of a static dataset? That'd one of the easiest solutions to guarantee
> that every listener is fully initialized.
>
> P T Withington wrote:
> > On 2007-09-03, at 09:41 EDT, Henry Minsky wrote:
> >> On 9/3/07, P T Withington <ptw at openlaszlo.org> wrote:
> >>
> >>> It would make sense to me that a static dataset would send an
> >>> 'ondata' event at startup.  It seems like a reasonable thing to
> >>> expect.
> >>>
> >>> But.  I bet that is going to raise the issue of what should happen if
> >>> someone sends an event and no one is listening.  It is easy for me to
> >>> imagine that a static dataset might send this event before the
> >>> relevant listeners have been initialized sufficiently to be
> >>> listening.
> >> I think that's what is happening, the startup for initialiazing the
> >> dataset calls this routine
> >> function setData( data , headers ) {
> >>     if ( data == null ) return;
> >>     if (data instanceof Array) {
> >>         this.setChildNodes( data );
> >>     } else {
> >>         this.setChildNodes( [data] );
> >>     }
> >>
> >>     this.data = data;
> >>
> >>     if ('responseheaders' in this && this.responseheaders != null) {
> >>         this.responseheaders.destroy();
> >>     }
> >>     this.responseheaders = headers;
> >>
> >>     if (this.ondata.ready) this.ondata.sendEvent( this );
> >> }
> >>
> >> And I suspect that the last line, "if (this.ondata.ready) " is
> >> returning false because
> >> some listener isn't set yet (what makes an event "ready"?)
> >>
> >
> > Well I would propose a wakeup-waiting solution, but I think that is
> > too risky for Wafflecone.  Note that implementing that would mean we
> > would lose Max's .ready optimization.
>
> --
> Official OpenLaszlo-Committer ^_^
>


-- 
Henry Minsky
Software Architect
hminsky at laszlosystems.com



More information about the Laszlo-dev mailing list