I'm trying to create a process that checks a dir every few seconds/milliseconds and process the files in it, is the below acceptable in Erlang?
init(Dir) -> loop(Dir).
loop(Dir) ->
check_dir(Dir),
spawn(fun() -> do_something(File) end),
timer:sleep(5).
loop(Dir).