Skip to content

jhbrown94/experimental-elm-viewlogger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a quick hack to demonstrate how one might log from an Elm view function using a custom element.

To snag this for your own project, you'd grab these files:

  • src/ViewLogger.elm
  • logger.js

In your index.html <head>, put:

	<script src="/logger.js"></script>

Then in your Elm view function, if you want to log something, use ViewLogger.log to put a hidden custom element in your Html as such:

ViewLogger.log {url = "https://path/to/post", data = mydata |> myDataJsonEncoder} 

This will post a log entry when it's first introduced into the view, and then whenever the data value changes.

You will want to modify how logger.js formats log messages for your endpoint, of course.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published