{"action":"closed","issue":{"url":"https://api.github.com/repos/kamilfb/mqtt-spy/issues/127","repository_url":"https://api.github.com/repos/kamilfb/mqtt-spy","labels_url":"https://api.github.com/repos/kamilfb/mqtt-spy/issues/127/labels{/name}","comments_url":"https://api.github.com/repos/kamilfb/mqtt-spy/issues/127/comments","events_url":"https://api.github.com/repos/kamilfb/mqtt-spy/issues/127/events","html_url":"https://github.com/kamilfb/mqtt-spy/issues/127","id":341553097,"node_id":"MDU6SXNzdWUzNDE1NTMwOTc=","number":127,"title":"Load script with common functions","user":{"login":"Haringat","id":3000678,"node_id":"MDQ6VXNlcjMwMDA2Nzg=","avatar_url":"https://avatars1.githubusercontent.com/u/3000678?v=4","gravatar_id":"","url":"https://api.github.com/users/Haringat","html_url":"https://github.com/Haringat","followers_url":"https://api.github.com/users/Haringat/followers","following_url":"https://api.github.com/users/Haringat/following{/other_user}","gists_url":"https://api.github.com/users/Haringat/gists{/gist_id}","starred_url":"https://api.github.com/users/Haringat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Haringat/subscriptions","organizations_url":"https://api.github.com/users/Haringat/orgs","repos_url":"https://api.github.com/users/Haringat/repos","events_url":"https://api.github.com/users/Haringat/events{/privacy}","received_events_url":"https://api.github.com/users/Haringat/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-07-16T14:54:12Z","updated_at":"2018-07-16T15:07:33Z","closed_at":"2018-07-16T15:07:33Z","author_association":"NONE","body":"I am trying to use the scripting capabilities, but since my topics are rather large (but structured) I would like to be able to put something like a publish() function in a script file where I only need to fill in one part that changes and require that script in all my other script to reduce boilerplate.\r\nSo it would look something like this:\r\ncommon.js\r\n```js\r\nfunction publish(topic, payload) {\r\n    mqtt.publish(\"device1/cmd/${topic}/fmt/json\", JSON.stringify(payload), 2, false);\r\n}\r\n```\r\nfoo.js\r\n```js\r\nload(\"./common.js\");\r\npublish(\"foo\", {\r\n    foo: \"bar\"\r\n});\r\n```\r\nbar.js\r\n```js\r\nload(\"./common.js\");\r\npublish(\"bar\", {\r\n    baz: \"foobar\"\r\n});\r\n```\r\nsadly, nashorn's load() function doesn't seem to work. Whenever that one is in the code, it fails. Or am I doing something wrong?"}}
{"actor":{"display_login":"Haringat"}}