Re: Asynchronous update from web server
Esteban Maringolo <[email protected]>
| Newsgroups | gmane.comp.lang.smalltalk.squeak.seaside |
|---|---|
| Message-ID | <CAJMgPCJXYkGr2aOWc110AxdYuBg8T4mLJLiiP3vZ0gVBUzeKLg@mail.gmail.com> |
But using interval() is wrong. You're creating one new interval on every call! And it doesn't have to be recursive. Maybe instead of #setInterval: it is #interval: in your image. Regards, El mar., 9 de abr. de 2019 11:30, [email protected] < [email protected]> escribió: > Ciao, > > thanks. > > > El lun., 8 abr. 2019 a las 7:48, [email protected] > > (<[email protected]>) escribió: > > > >> In my case i haven't any user actions on the client. > >> The client display some data with dynamic banner ( marquee tag ) > >> and i need to update it only when the data to display change > from the server. > >> When the data on the server relative to an banner change i need > to force the clients banners update. > >> it seems to me that your initial solution may be fine. > >> > >> What do you think? > > > > Too complex for such a simple task. > > > > Is the <marquee> tag still a thing? I though it dissapeared when > > Geocities closed. :) > > > > See below my suggestion. > > > > > >> Another solution could be to manage an client ajax request with > a specific interval > >> but update the relative banner div only if the related data > received from the server changed. > >> ( But how i can manage it? > >> Can i not reply to an client ajax request > >> or respond to doing nothing and continue to view > the current status ) > > > > You can have a recursive call to setInterval() that returns a script > > (javascript) that updates the mentioned banner, and if no update is > > necessary you do nothing. Doing it once per minute is nothing for the > > server, since it's a simple AJAX call, which if nothing needs > > updating, is fast to answer. > > > > These are the key parts: > > > > renderContentOn: html > > self renderBannerOn: html. > > html script: (html jQuery script: [ :script | self scriptUpdaterOn: > script ]) > > > > scriptUpdaterOn: aJSScript > > aJSScript << > > ((aJSScript jQuery ajax > > script: [ :s | > > self shouldUpdate ifTrue: [ self scriptBannerUpdateOn: s ]. > > self scriptUpdaterOn: s ]) setTimeout: 1 minute) > > The setTimeout is not implemented in my system. > > With timeout: i have some problematic. > > I change the scriptUpdaterOn: aJSScript to: > > scriptUpdaterOn: aJSScript > aJSScript < > ((aJSScript jQuery ajax > script: [ :s | > self shouldUpdate ifTrue: [ self > scriptBannerUpdateOn: s ]. > ]) interval: 1 minute) > > It works very well relatively to my current needs. > > Dario > > > > > scriptBannerUpdateOn: s > > s << ((s jQuery id: 'banner') replaceWith: [ :h | self renderBannerOn: > h ]) > > > > Attached to this mails goes a working example of this. > > > > In #scriptBannerUpdateOn: I would put all the logic, even by replacing > > the whole component as a whole (sometimes the best compromise) or > > indidividual elements within it). > > > > > > > > Regards, > > > > Esteban A. Maringolo > > <EAMRecursiveTimeout.st>_______________________________________________ > > seaside mailing list > > [email protected] > > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside > > _______________________________________________ > seaside mailing list > [email protected] > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside > _______________________________________________ seaside mailing list [email protected] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside