docs: update changelog and docs referencing how objects are userdata

userdata
TorchedSammy 2022-05-28 17:24:14 -04:00
parent e656b8f210
commit 10337af11e
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
3 changed files with 19 additions and 5 deletions

View File

@ -56,6 +56,9 @@ This is probably one of (if not the) biggest things in this release.
user input, exit code, and error. User input has been added to the return to
account for runners wanting to prompt for continued input, and to add it
properly to history.
- **Breaking Change:** Job objects and timers are now Lua userdata instead
of a table, so their functions require you to call them with a colon instead
of a dot. (ie. `job.stop()` -> `job:stop()`)
- All `fs` module functions which take paths now implicitly expand ~ to home.
### Fixed

View File

@ -20,8 +20,11 @@ and `execPath` is an absolute path for the command executable.
- `disown(id)`: Removes a job by ID from the job table.
# Job Object
A job object on the Lua side is a table with some functions.
On the under side it represents a job in the job table.
A job object is a piece of `userdata`. All the functions of a job require
you to call them with a colon, since they are *methods* for the job object.
Example: hilbish.jobs.last():foreground()
Which will foreground the last job.
You can still have a job object for a disowned job,
it just won't be *working* anywhere. :^)

View File

@ -16,9 +16,17 @@ a timer via ID.
when the timer is triggered.
# Timer Object
Those previously mentioned functions return a `timer` object, to which you can
stop and start a timer again. The functions of the timers interface also
return a timer object.
All those previously mentioned functions return a `timer` object, to which
you can stop and start a timer again.
An example of usage:
local t = hilbish.timers.create(1, 5000, function()
print 'hello!'
end)
t:stop()
print(t.running, t.duration, t.type)
t:start()
## Properties
- `duration`: amount of time the timer runs for in milliseconds