<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Here's something you might consider. In this case, I render a page
and then start gathering data to fill it. The "action" script gets
fired when the page loads and then fires again every time
"tinyThing" is clicked.<br>
<br>
<br>
<font face="Georgia">renderMiningOn: html<br>
| action myLoops buildFinished currData prevData |<br>
<br>
LOOPER := OrderedCollection new.<br>
myLoops := 0.<br>
miningPriceSelector ifNil: [miningPriceSelector := 2].<br>
self renderMiningPriceSelectorOn: html.<br>
prevData := currData := nil.<br>
buildFinished := false.<br>
html div id: 'incompleteTable001'; with: [].<br>
[<br>
self buildMiningData: [ :data :flag |<br>
prevData := currData.<br>
currData := data.<br>
buildFinished := flag.<br>
].<br>
] forkAt: Processor activePriority.<br>
<br>
action := html jQuery ajax<br>
script: [ :s | <br>
myLoops := myLoops + 1.<br>
myLoops > 100 ifTrue: [self halt].<br>
[currData == prevData & buildFinished not]
whileTrue: [<br>
(Delay forMilliseconds: 300) wait<br>
].<br>
currData ifNotNil: [<br>
s << (s jQuery: #incompleteTable001) html: [
:h | <br>
self renderMiningFrom: currData on: h<br>
].<br>
].<br>
buildFinished ifTrue: [<br>
s << ((s jQuery: #moretocome) html: [ :h | h
text: 'done']).<br>
] ifFalse: [<br>
s << ((s jQuery: #moretocome) html: [ :h | h
text: '...']).<br>
s << ((s jQuery: #tinyThing) trigger:
'click').<br>
]<br>
].<br>
html div id: 'moretocome'; with: [].<br>
html div <br>
id: 'tinyThing';<br>
onClick: action;<br>
with: [].<br>
html document addLoadScript: action</font><br>
<br>
<div class="moz-cite-prefix">On 2/28/15 2:01 PM, sergio_101 wrote:<br>
</div>
<blockquote
cite="mid:CABOFMNnSKYj8E3jkiLEKrUiBet7UCWJaCDxEyU6xTDq2AUa=tg@mail.gmail.com"
type="cite">
<div dir="ltr">ahhh.. i need to get this info for processing into
my image.. it will not be passed into the browser until much
later in the game. the reason i want to do it this way is so
that all this stuff is happening without the user having to wait
on it..<br>
<div><br>
</div>
<div>i will take a look at threadpool and futures..</div>
<div><br>
</div>
<div>thanks!<br>
<br>
</div>
</div>
<br>
<div class="gmail_quote">On Fri, Feb 27, 2015 at 10:12 PM Paul
DeBruicker <<a moz-do-not-send="true"
href="mailto:pdebruic@gmail.com">pdebruic@gmail.com</a>>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">Oh, and
futures:<br>
<br>
<a moz-do-not-send="true"
href="http://onsmalltalk.com/smalltalk-concurrency-playing-with-futures"
target="_blank">http://onsmalltalk.com/smalltalk-concurrency-playing-with-futures</a><br>
<br>
<br>
You probably want Futures if you're gonna poll from the
client.<br>
<br>
<br>
<br>
<br>
<br>
<br>
Paul DeBruicker wrote<br>
> Hmmmm.<br>
><br>
> In your plain English example is what you want happening
in the client<br>
> browser or in your smalltalk image, ideally?<br>
><br>
><br>
> If you want the friends data in your image then you
should consider using<br>
> Ramon Leon's ThreadPool:<br>
> <a moz-do-not-send="true"
href="http://onsmalltalk.com/2010-07-28-a-simple-thread-pool-for-smalltalk"
target="_blank">http://onsmalltalk.com/2010-07-28-a-simple-thread-pool-for-smalltalk</a>
.<br>
> I've kept it working here: <a moz-do-not-send="true"
href="http://smalltalkhub.com/#%21/%7Epdebruic/ThreadPool"
target="_blank">http://smalltalkhub.com/#!/~pdebruic/ThreadPool</a><br>
> You could use it to get the friends data from Facebook
into the image.<br>
> Then poll for results from the client to update any
divs/views. You can<br>
> queue the thread pool requests in your login callback
before you even<br>
> begin rendering things.<br>
><br>
><br>
><br>
> If you just want to load the friends into a div only in
the client its<br>
> probably easier to write a JS function in an external
file and call it<br>
> from Seaside using the info specific to the user. e.g.<br>
><br>
> html div<br>
> id:'friendList'<br>
> script: ((html jQuery id: 'friendList') call:
'loadFriendList' with:<br>
> self userFacebookID).<br>
><br>
><br>
><br>
> Look at the JSScript class for the definition of
#<< . It just<br>
> concatenates the scripts. The #script: method passes a
stream into the<br>
> block, and the << writes whatever you've written
onto that stream. Check<br>
> the senders and implementors to get your bearings.<br>
><br>
><br>
> When you have time please send things like:<br>
><br>
> "I think this code "____code example_____" should do
"____expected<br>
> behavior____" but instead it does "____jumbly
voodoo_____" instead. What<br>
> don't I understand?<br>
><br>
><br>
> Hope this helps.<br>
><br>
><br>
> Paul<br>
><br>
> sergio_101 wrote<br>
>> i think i am having alot of difficulty understanding
out to phrase ajax<br>
>> and<br>
>> jquery calls in seaside.. everywhere else, i use
jquery etc<br>
>> unobtrusively..<br>
>> so i don't leave the javacript world when i write
javascript. i just<br>
>> can't<br>
>> seem to find anything that makes sense on how to do
something as simple<br>
>> as<br>
>> this using pure seaside/smalltalk.<br>
>><br>
>> i can't really even understand what the "<<"
in:<br>
>> script: [ :s | s << (s jQuery: #logger) html:
DateAndTime now<br>
>> ]);<br>
>> does..<br>
>><br>
>> in plain english, i would like to do this:<br>
>><br>
>> - when the page loads, call the url as an ajax
function<br>
>> - set the variable -> currentUser friendsList:
(from the above)<br>
>><br>
>> but i am not understanding how to even code this..<br>
>><br>
>> thanks!<br>
>><br>
>><br>
>><br>
>><br>
>><br>
>> On Fri, Feb 27, 2015 at 3:27 PM Sebastian Sastre <<br>
<br>
>> sebastian@<br>
<br>
>>> wrote:<br>
>><br>
>>> why the fork that way?<br>
>>><br>
>>> I’d think more into make it a normal render page
that has a little piece<br>
>>> of javascript that will do an ajax hit to a
server callback to do<br>
>>> whatever<br>
>>> you want, no?<br>
>>><br>
>>><br>
>>><br>
>>><br>
>>> > On Feb 27, 2015, at 1:45 PM, sergio_101
&lt;<br>
<br>
>> sergio.rrd@<br>
<br>
>> &gt; wrote:<br>
>>> ><br>
>>> > i am currently writing a facebook
application in seaside. one of the<br>
>>> most important pieces of data i need to retrieve
is the user's friends<br>
>>> list. unfortunately, this could end up being a
substantial amount of<br>
>>> data.<br>
>>> fortunately, the load time for this data is not
horrible, just a few<br>
>>> seconds.<br>
>>> > i am making the assumption that while
interacting with my app, the<br>
>>> user<br>
>>> will not be adding new friends mid stream, and
that during each session,<br>
>>> the friends list will be static.<br>
>>> ><br>
>>> > what i would like to do is make this happen
completely behind the<br>
>>> scenes, so that when the user logs in, the
request for the friends list<br>
>>> is<br>
>>> fired off RIGHT AFTER the page is rendered.<br>
>>> > i read the section on concurrency in 'deep
into pharo', and while<br>
>>> incomplete, it makes enough sense for me to try
it.<br>
>>> > my question is.. i am going to do something
like:<br>
>>> ><br>
>>> > [currentUser updateData] fork<br>
>>> ><br>
>>> > 1. if i want to do that RIGHT AFTER
rendering, can i put that at the<br>
>>> end<br>
>>> of renderContentOn: html ?<br>
>>> > 2. when i want to work with the data, how
would i know if it was done<br>
>>> updating? i was thinking of using a semaphore..
but how would i let the<br>
>>> next process know to keep waiting until the
process was done? i would<br>
>>> want<br>
>>> to do something like: getFriendsList (but make
sure process that<br>
>>> populates<br>
>>> it is done before running the request).<br>
>>> ><br>
>>> > thanks!<br>
>>> > _______________________________________________<br>
>>> > seaside mailing list<br>
>>> ><br>
<br>
>> <a class="moz-txt-link-abbreviated" href="mailto:seaside@.squeakfoundation">seaside@.squeakfoundation</a><br>
<br>
>>> > <a moz-do-not-send="true"
href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside"
target="_blank">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside</a><br>
>>><br>
>>> _______________________________________________<br>
>>> seaside mailing list<br>
>>><br>
<br>
>> <a class="moz-txt-link-abbreviated" href="mailto:seaside@.squeakfoundation">seaside@.squeakfoundation</a><br>
<br>
>>> <a moz-do-not-send="true"
href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside"
target="_blank">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside</a><br>
>>><br>
>><br>
>> _______________________________________________<br>
>> seaside mailing list<br>
<br>
>> <a class="moz-txt-link-abbreviated" href="mailto:seaside@.squeakfoundation">seaside@.squeakfoundation</a><br>
<br>
>> <a moz-do-not-send="true"
href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside"
target="_blank">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside</a><br>
<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a moz-do-not-send="true"
href="http://forum.world.st/Concurrent-Programming-tp4808376p4808475.html"
target="_blank">http://forum.world.st/Concurrent-Programming-tp4808376p4808475.html</a><br>
Sent from the Seaside General mailing list archive at
Nabble.com.<br>
_______________________________________________<br>
seaside mailing list<br>
<a moz-do-not-send="true"
href="mailto:seaside@lists.squeakfoundation.org"
target="_blank">seaside@lists.squeakfoundation.org</a><br>
<a moz-do-not-send="true"
href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside"
target="_blank">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside</a><br>
</blockquote>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
seaside mailing list
<a class="moz-txt-link-abbreviated" href="mailto:seaside@lists.squeakfoundation.org">seaside@lists.squeakfoundation.org</a>
<a class="moz-txt-link-freetext" href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside</a>
</pre>
</blockquote>
<br>
</body>
</html>