Receiving and Loading Data with an insert-notify Callback
To display the changed data to other users, you extend the
load-sheets function in this second extension of Nano-Sheets so that when the send-server action above results in a new or updated spreadsheet, the
insert-notify callback function will load the data. Here's the entire
load-sheet file so you can see where to add the new code (after the
;--- comment).
last-file: none
load-sheet: func [file [file! url!] /local data] [
collab-file: second split-path file
clear-sheet
parse load/all file sheet==
;---Add this code to receive and load synced
;---spreadsheets
if all [ link? (last-file <> collab-file )] [
base-dir: any [ ( find/match what-dir
link-root ) what-dir]
remove-notify 'file-downloaded
base-dir/:last-file
last-file: collab-file
insert-notify 'file-downloaded
base-dir/:collab-file func [a data][
load-sheet collab-file
]
]
current-file: file
show lay
compute
]
After adding this new code, all users who are given access to the
nano-sheets fileset will receive the new file the next time their REBOL/IOS client connects to the X-Internet. This simple example assumes that users who want to see the spreadsheet when it is synced have Nano-Sheets running; if they do, it will load the file if you added the preceding code.
This example simply uses Nano-Sheets to receive and load the file, but you could add a management program to the
nano-sheets fileset that loads the data and uses it to automate workflow.
Note that it requires only about 500 bytes to extend Nano-Sheets for collaboration with either itself, or with other programs.
The
link? test lets Nano-Sheets operate with any version of REBOL, even without the X-Internet, or without any connection at all.
We hope you now appreciate the revolutionary design of Nano-Sheets as shown in the examples. REBOL enables concise, readable code that's tiny compared to other software technologies. The Nano-Sheets application is just an appetizer of what's possible with REBOL; and we hope these servings were palatable. You don't need a huge team of programmers to produce professional results using this example as a starting point.
Please refer to the sidebar "
Major Benefits of REBOL" to see a further analysis of how REBOL functions under the hood of Nano-Sheets.