bahmutov / bahmutov/cycle-devtool-in-electron

Can it load Node xstream program?

Open
#1 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Like loading a file like
```js
const http = require('http');
const {default: xs, MemoryStream} = require('xstream');
// console.log('MemoryStream', MemoryStream)
// const xs = require('xstream');
// console.log(xs)
const {tap, propEq, pathEq} = require('ramda')

const server = http.createServer();

// A *producer* is something that produces values for the observable
const serverProducer = {
start: listener => {
server.on('request', (req, res) => {
// Each time we get an HTTP request, send an object with the
// request object and response object as properties
listener.next({ req, res });
})
},
stop: () => server.close(),
id: 0
};

const logIn = ({req}) => console.log('-->', req.method, req.url)
const logOut = ({req, res}) =>
console.log('<--', req.method, req.url, res.statusCode)

const server$ = xs.create(serverProducer)
// .map(tap(log))
.debug(logIn)

const index$ = server$
// .filter(({req}) => req.url === '/')
// .filter(propEq('url', '/'))
.filter(pathEq(['req', 'url'], '/'))
.map(({req, res}) => {
res.end('hello, world')
return {req, res}
})

const notFound$ = server$
.filter(({req}) => req.url !== '/')
.map(({req, res}) => {
res.statusCode = 404
res.statusMessage = 'Not Found'
res.end()
return {req, res}
})

xs.merge(index$, notFound$)
.debug(logOut)
.addListener({
next: () => {},
error: console.error
});

server.listen(3000);
```
and visualize its running?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by examining how this Electron project currently opens local files or remote URLs and how the Cycle DevTool panel visualizes them. Use the supplied Node.js xstream example as the target program, and consider the work done when that program can be loaded, run, and visualized.

Written by the indexing model from the issue text.

Assessment

Tech stack
electron, javascript, node.js
Domain
devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.