aboutsummaryrefslogtreecommitdiff
path: root/src/content/chapter5_advance_features/lesson04_externals/code.gleam
blob: be4aff081b9b8fcbee5da51ac9d8d9d9bab5068b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import gleam/io

// A type with no Gleam constructors
pub type DateTime

// An external function that creates an instance of the type
@external(javascript, "./my_package_ffi.mjs", "now")
pub fn now() -> DateTime

// The `now` function in `./my_package_ffi.mjs` looks like this:
// external function now() {
//   return new Date();
// }

pub fn main() {
  io.debug(now())
}