![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
RxWS is a RESTful reactive JavaScript implementation on top of web sockets. This includes,
GET
, POST
, PUT
, REMOVE
(DELETE), PATCH
, and HEAD
. RxWS guarantees message delivery by generating
a correlation id for each message (to and from the server). Both the server and client automatically send an
acknowledgement response for each request. If there is no acknowledgement after a timeout, an error is thrown.
RxWS implements a RESTful protocol. You can use any websocket server as long as it implements the same protocol. By default RxWS supports SocketIO with rxws-socketio
RxWS requires a websocket abstraction layer. By default it supports both SockJS and SocketIO.
import rxws from 'rxws';
import SocketIOBackend from 'rxws-socketio/SocketIOBackend';
rxws.setBackend({
backend: SocketIOBackend,
url: 'ws://someurl'
});
rxws.get('users')
.subscribe(data => console.log)
.catch(error => console.error)
Performing a GET
request:
// Request all users
rxws.get('users')
.subscribe(data => console.log, error => console.error)
// Request a specific user
rxws.get('users', {
parameters: { 'users': 13 }
})
.subscribe(data => console.log, error => console.error)
// Optionally the request could have been built with
rxws({
method: 'get',
resource: 'users',
parameters: { 'users': 13 }
})
.subscribe(data => console.log, error => console.error)
Performing a POST
request:
// Create a user
rxws.post('users', {
firstName: 'Johnny',
lastName: 'Appleseed'
})
.subscribe(data => console.log, error => console.error)
// Optionally the request could have been built with
rxws({
method: 'post',
resource: 'users',
body: {
firstName: 'Johnny',
lastName: 'Appleseed'
}
})
.subscribe(data => console.log, error => console.error)
Nested resources:
// Request a comment from a specific post
rxws.get('posts.comments', {
parameters: { 'posts': 13, 'comments': 15 }
})
.subscribe(data => console.log, error => console.error)
Custom headers:
// Request all comments from a post
rxws.get('posts.comments', {
parameters: { 'posts': 13 },
apiVersion: '1.2.1',
accessToken: '7fgnasdfvy0afdsjfjdls',
queryParameters: { include: 'history' }
})
.subscribe(data => console.log, error => console.error)
Server Notifications:
// Listen for new posts
rxws.onNotification('newPost')
.forEach((messageBody) => {
rxws.get('posts', { parameters: { posts: messageBody.id } })
.subscribe(data => console.log, error => console.error);
})
Middleware:
// Middleware progress from one another in the order they are defined
rxws.use()
.subscribe(({res, reply, retry, next}) => {
res.requestTime = Date.now();
next();
});
rxws.use()
.subscribe(({res, reply, retry, next}) => {
reply(res);
});
// Use middleware to retry requests
rxws.use()
.subscribe(({res, reply, retry, next}) => {
if (res.header.statusCode === 401) {
auth.refreshAuthToken()
.then(() => retry())
} else {
reply(res);
}
})
Reactive example:
// Try three times to get the data and then return cached data if still fails
var source = rxws.get('url').retry(3).catch(cachedVersion());
var subscription = source.subscribe(
(data) => {
// Displays the data from the URL or cached data
console.log(data);
}
);
rxws.setBackend(options)
rxws.setBackend({
backend: rxwsBackendImplementation,
url: string,
defaultHeaders?: object,
requestTransformer?: (request: object, send: Function): null,
responseTransformer?: (response: object, reply: Function, retry: Function): null,
timeout?: 10000,
onConnectionError?: (error: string): null
})
rxws(config): observable
rxws({
method: 'get',
resource: 'posts',
parameters: { 'posts': 13 }
});
rxws.get(resource[, config]): observable
rxws.delete(resource[, config]): observable
rxws.head(resource[, config]): observable
rxws.post(resource[, data[, config]]): observable
rxws.put(resource[, data[, config]]): observable
rxws.patch(resource[, data[, config]]): observable
rxws.onMessage(type: string): observable
FAQs
A RESTful reactive JavaScript implmentation on top of web sockets
The npm package rxws receives a total of 1 weekly downloads. As such, rxws popularity was classified as not popular.
We found that rxws demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.