Is there a good reason *not* to use a port for this? The difficultly level
is very low, and t's a single js function call.
Also, don't even consider a native module at all. The general consensus is
that native code isn't meant for the general Elm population, because it has
the ability to absolutely break all guarantees that Elm initially promises.
One main issue here is that Elm, being a functional language, needs a value
returned after a function call. Sure, you could have something like `print
: () -> Bool`, but that's not quite correct because you are adding extra
meaningless data (ie passing a tuple and returning a bool, both unrelated
to print). As a result, it's much better suited to be a Task (port
function), since tasks don't return values, and there is no logical thing
to return.
From personal experience, don't even consider native modules unless:
1. Elm does not have the ability to support the feature you want.
2. Sending a message to run a task makes performing the function awkward.
99% of the time for printing the screen, it's because the user is clicking
a button on the page, and that's a super simple update from Elm.
Post by Casper BollenIs there an Elm way to implement window.print() without using a javascript
port?
--
You received this message because you are subscribed to the Google Groups "Elm Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elm-discuss+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.