-
-
Save earl/447e4e9510a68c308f6b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rebol [title: "GUI & Async HTTP Demo" author: 'abolka date: 2013-06-18] | |
load-gui | |
do-download: closure [url-field content-area /local url port] [ | |
url: to-url get-face url-field | |
port: make port! url | |
port/awake: funct [event] [ | |
switch event/type [ | |
connect [ | |
;; Use HTTP's READ actor to send the HTTP request once we are | |
;; connected. | |
read event/port | |
] | |
read [ | |
;; Schedule the low-level TCP port for further reading. | |
;; (@@ Smells! Should be taken care of by the HTTP scheme.) | |
read event/port/state/connection | |
] | |
done [ | |
;; Use HTTP's COPY actor to read the full website content once | |
;; reading is finished. | |
set-face content-area to-string copy event/port | |
close event/port | |
return true | |
] | |
] | |
false | |
] | |
open port | |
] | |
view [ | |
vpanel [ | |
title "Async HTTP GUI Demo" | |
hpanel [ | |
text "URL" | |
url-field: field "http://rebolsource.net/" | |
] | |
content-area: area | |
hpanel [ | |
button "Download" on-action [ | |
do-download url-field content-area | |
] | |
button "Quit" on-action [ | |
quit | |
] | |
] | |
] | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment