Skip to content
This repository was archived by the owner on Dec 21, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
{
"presets": ["env"],
"plugins": ["babel-plugin-add-module-exports",
["transform-runtime", {
"polyfill": false,
"regenerator": true
}]]
"presets": ["env", "stage-2"],
"plugins": ["babel-plugin-add-module-exports"]
}
5 changes: 3 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
module.exports = exports = {
extends: 'streamr',
env: {
mocha: true,
},
rules: {
// Transpiling for node would add a lot of complexity, se let's accept having to write CommonJS modules

'no-plusplus': ["error", { "allowForLoopAfterthoughts": true }],
'no-underscore-dangle': ["error", { "allowAfterThis": true }]
}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ node_modules
*.iml
.DS_Store
dist/*
examples/webpack/dist/*
73 changes: 73 additions & 0 deletions examples/node/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"description": "Using streamr-client in node",
"main": "node.js",
"dependencies": {
"streamr-client": "0.10.0"
"streamr-client": "^0.10.2"
}
}
53 changes: 0 additions & 53 deletions examples/web/browser.html

This file was deleted.

42 changes: 42 additions & 0 deletions examples/web/web-example-produce.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<html>
<head>
<!-- For debug messages, include debug.js and set localStorage.debug = 'StreamrClient'. See from https://github.com/visionmedia/debug -->
<script src="../../dist/streamr-client.web.min.js"></script>

<script>
const log = (msg) => {
var elem = document.createElement('p')
elem.innerHTML = msg
document.body.appendChild(elem)
}

const STREAM_ID = 'MY-STREAM-ID'
const API_KEY = 'MY-API-KEY'

// Create the client and give the API key to use by default
const client = new StreamrClient({
restUrl: 'http://localhost:8890/api/v1',
apiKey: API_KEY
})

function produce() {
// Here is the event we'll be sending
const msg = {
hello: 'world',
random: Math.random()
}

// Produce the event to the Stream
client.produceToStream(STREAM_ID, msg)
.then(() => console.log('Sent successfully: ', msg))
.catch((err) => log(err))
}
</script>
</head>
<body>
<button id="produce">Produce</button>
<script>
document.getElementById('produce').addEventListener('click', produce)
</script>
</body>
</html>
50 changes: 50 additions & 0 deletions examples/web/web-example-subscribe.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<html>
<head>
<!-- For debug messages, include debug.js and set localStorage.debug = 'StreamrClient'. See from https://github.com/visionmedia/debug -->
<script src="../../dist/streamr-client.web.min.js"></script>

<script>
const log = (msg) => {
var elem = document.createElement('p')
elem.innerHTML = msg
document.body.appendChild(elem)
}

// Create the client with default options
const client = new StreamrClient()

// Subscribe to a stream
const subscription = client.subscribe({
stream: '7wa7APtlTq6EC5iTCBy6dw',
// Resend the last 10 messages on connect
resend_last: 10,
}, (message) => {
// Handle the messages in this stream
log(JSON.stringify(message))
})

// Event binding examples
client.on('connected', function() {
log('A connection has been established!')
})

subscription.on('subscribed', function() {
log('Subscribed to ' + subscription.streamId)
})

subscription.on('resending', function() {
log('Resending from ' + subscription.streamId)
})

subscription.on('resent', function() {
log('Resend complete for ' + subscription.streamId)
})

subscription.on('no_resend', function() {
log('Nothing to resend for ' + subscription.streamId)
})
</script>
</head>
<body>
</body>
</html>
4 changes: 4 additions & 0 deletions examples/webpack/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"presets": ["env", "stage-2"],
"plugins": ["babel-plugin-add-module-exports"]
}
Empty file added examples/webpack/dist/.gitkeep
Empty file.
9 changes: 9 additions & 0 deletions examples/webpack/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<html>
<head>
</head>
<body>
<button id="subscribe">Subscribe</button>
<button id="produce">Produce</button>
<script src="./dist/webpack-example.js"></script>
</body>
</html>
Loading