Node.Program
A NodeJS program is defined like most other Gren programs, except that there is more flexibility regarding how it is initialized.
You can initialize any number of subsystems, like FileSystem
or Terminal
, before
initializing your own program with the results of those initializations.
As part of initializing a subsystem, you usually also get access to a value that permits you to contact said subsystem. Be careful what code you give these permissions to.
Simple Program
A simple program that executes a single task and then exits.
Define a simple program that doesn't require long-lived state or the ability to respond to messages or subscriptions. Ideal for simple and short-lived programs.
When defining a program with defineTask
, use this function to define the
final command to execute.
Program
The definition of a Gren program that runs on NodeJS.
The required functions that define a program.
Define a program with access to long-lived state and the ability to respond to
messages and listen to subscriptions. If you want to define a simple and short-lived
program, chances are you're looking for defineSimple
instead.
This lets the runtime know that you're done initializing other subsystems, and that your program is ready to start.
Initialization
This is like a Task
, but can only be run as part of initializing your
program. This is usually used for values which should be provided to your program,
and only your program, as opposed to third-party packages.
This let's you wait for the completion of an AppInitTask
before either starting
your application, or begin initialization of another AppInitTask
.
Program.await Node.initialize <| \nodeConfig ->
Program.await FileSystem.initialize <| \fileSystemConfig ->
-- Start your own program with the values from Node and FileSystem
Program.startProgram
{ model = 1
, commands = Cmd.none
}
This let's you wait for the completion of a Task
before either starting
your application, or begin initialization of another AppInitTask
.
Program.await Node.initialize <| \nodeConfig ->
Program.awaitTask Task.now <| \time ->
-- Start your own program with the values from Node and FileSystem
Program.startProgram
{ model = time
, commands = Cmd.none
}