{"action":"created","issue":{"url":"https://api.github.com/repos/egoist/maid/issues/27","repository_url":"https://api.github.com/repos/egoist/maid","labels_url":"https://api.github.com/repos/egoist/maid/issues/27/labels{/name}","comments_url":"https://api.github.com/repos/egoist/maid/issues/27/comments","events_url":"https://api.github.com/repos/egoist/maid/issues/27/events","html_url":"https://github.com/egoist/maid/issues/27","id":328985695,"node_id":"MDU6SXNzdWUzMjg5ODU2OTU=","number":27,"title":"[ Feature request ] Connecting code blocks through pipes. ","user":{"login":"AlvaroBernalG","id":12004383,"node_id":"MDQ6VXNlcjEyMDA0Mzgz","avatar_url":"https://avatars0.githubusercontent.com/u/12004383?v=4","gravatar_id":"","url":"https://api.github.com/users/AlvaroBernalG","html_url":"https://github.com/AlvaroBernalG","followers_url":"https://api.github.com/users/AlvaroBernalG/followers","following_url":"https://api.github.com/users/AlvaroBernalG/following{/other_user}","gists_url":"https://api.github.com/users/AlvaroBernalG/gists{/gist_id}","starred_url":"https://api.github.com/users/AlvaroBernalG/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlvaroBernalG/subscriptions","organizations_url":"https://api.github.com/users/AlvaroBernalG/orgs","repos_url":"https://api.github.com/users/AlvaroBernalG/repos","events_url":"https://api.github.com/users/AlvaroBernalG/events{/privacy}","received_events_url":"https://api.github.com/users/AlvaroBernalG/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-06-04T09:53:30Z","updated_at":"2018-06-11T15:57:38Z","closed_at":null,"author_association":"NONE","body":"Hello good people of maid,\r\n\r\nIt would be useful if code blocks could communicate somehow. \r\n\r\n## Stdin - stdout \r\n\r\nIn the following pattern the code blocks are connected through the stdin-stdout: \r\n\r\n````markdown\r\n\r\n## build \r\n\r\nBuilds important stuff \r\n\r\nSnippet 1 \r\n\r\n```js\r\nprocess.stdout.write(\"hi there from snippet 1\");\r\n```\r\n\r\nSnippet 2\r\n\r\n```js\r\nprocess.stdin.on('data', console.log); // hi there from snippet 1\r\n```\r\n\r\n````\r\n\r\n## Next \r\n\r\nAnother way of allowing communication between code blocks is by injecting a method inside each code block in a similar way of how `express.js` does it with their middlwares. \r\n\r\n````markdown\r\n\r\n## build \r\n\r\nBuilds important stuff \r\n\r\nCode block 1 \r\n\r\n```js\r\nnext('hi there from snippet 1');\r\n```\r\n\r\nCode block 2\r\n\r\n```js\r\nconsole.log(maid.result); // hi there from snippet 1\r\n```\r\n\r\n````\r\n\r\nThis pattern can also be used to control the execution flow: \r\n\r\n````markdown\r\n\r\n## build \r\n\r\nBuilds important stuff \r\n\r\nCode block 1 \r\n\r\n```js\r\nnext('hi there from snippet 1');\r\n```\r\n\r\nCode block 2\r\n\r\n```js\r\nif (true) {\r\n\tconsole.log(maid.result); // hi there from snippet 1\r\n}else {\r\n\tnext(\"hi there from snippet 2\");\r\n}\r\n```\r\n\r\nCode block 3 \r\n\r\n```bash\r\n // This will never get executed \r\n\r\n```\r\n````\r\n\r\n \r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/egoist/maid/issues/comments/396294161","html_url":"https://github.com/egoist/maid/issues/27#issuecomment-396294161","issue_url":"https://api.github.com/repos/egoist/maid/issues/27","id":396294161,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NjI5NDE2MQ==","user":{"login":"olstenlarck","id":5038030,"node_id":"MDQ6VXNlcjUwMzgwMzA=","avatar_url":"https://avatars3.githubusercontent.com/u/5038030?v=4","gravatar_id":"","url":"https://api.github.com/users/olstenlarck","html_url":"https://github.com/olstenlarck","followers_url":"https://api.github.com/users/olstenlarck/followers","following_url":"https://api.github.com/users/olstenlarck/following{/other_user}","gists_url":"https://api.github.com/users/olstenlarck/gists{/gist_id}","starred_url":"https://api.github.com/users/olstenlarck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olstenlarck/subscriptions","organizations_url":"https://api.github.com/users/olstenlarck/orgs","repos_url":"https://api.github.com/users/olstenlarck/repos","events_url":"https://api.github.com/users/olstenlarck/events{/privacy}","received_events_url":"https://api.github.com/users/olstenlarck/received_events","type":"User","site_admin":false},"created_at":"2018-06-11T15:57:38Z","updated_at":"2018-06-11T15:57:38Z","author_association":"CONTRIBUTOR","body":"@egoist yea, i'm curious to hear too.\r\n\r\nIf we decide to do it, it looks like that we should add some global variables like `maid` and `next` to the content when we execute the js code snippet. Which not sounds like a good thing."}}
{"actor":{"display_login":"olstenlarck"}}