rxjs-ws-channels-filters
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -242,2 +242,4 @@ 'use strict'; | ||
invalidUrl: userOptions.invalidUrl, | ||
transformResponse: userOptions.transformResponse, | ||
transformRequest: userOptions.transformRequest, | ||
channelJoinAction: userOptions.channelJoinAction || defaultOptions.channelJoinAction, | ||
@@ -272,7 +274,15 @@ channelLeaveAction: userOptions.channelLeaveAction || defaultOptions.channelLeaveAction, | ||
inputSubscription = vm.subject.subscribe(function (data) { | ||
socket.send(JSON.stringify(data)); | ||
var message = data; | ||
if (vm.options.transformRequest) { | ||
message = vm.options.transformRequest(JSON.parse(JSON.stringify(message))); | ||
} | ||
socket.send(JSON.stringify(message)); | ||
}); | ||
}; | ||
socket.onmessage = function (message) { | ||
observer.next(JSON.parse(message.data)); | ||
socket.onmessage = function (response) { | ||
var message = JSON.parse(response.data); | ||
if (vm.options.transformResponse) { | ||
message = vm.options.transformResponse(message); | ||
} | ||
observer.next(message); | ||
}; | ||
@@ -279,0 +289,0 @@ socket.onerror = function (error) { |
{ | ||
"name": "rxjs-ws-channels-filters", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "RxJS websockets implementation with channels and filters", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -17,2 +17,15 @@ # rxjs-ws-channels-filters | ||
}); | ||
}, | ||
transformResponse: function (message) { | ||
return message; | ||
}, | ||
transformRequest: function (message) { | ||
if (message.filters && message.filters.length) { | ||
var i = message.filters.length - 1; | ||
for (; i > -1; i--) { | ||
message.filters[i].type = message.channel; | ||
} | ||
} | ||
return message; | ||
} | ||
@@ -52,5 +65,3 @@ }; | ||
* add option for user custom filtering of channel and filters | ||
* add option for user custom message modifier when message arrives | ||
* add option for user custom message modifier before message sent to server | ||
* make a separate repo with a server side node implementation | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
13301
291
66
0