New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

stimulus_reflex

Package Overview
Dependencies
Maintainers
1
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stimulus_reflex - npm Package Compare versions

Comparing version 0.3.7 to 1.0.0

5

package.json
{
"name": "stimulus_reflex",
"version": "0.3.7",
"version": "1.0.0",
"main": "./src/index.js",

@@ -13,5 +13,4 @@ "repository": {

"actioncable": "^5.2.3",
"cable_ready_client": "^3.0.4",
"stimulus": "^1.1.1"
"cable_ready": "^4.0.0"
}
}

49

README.md

@@ -0,48 +1,7 @@

[![Lines of Code](http://img.shields.io/badge/lines_of_code-35-brightgreen.svg?style=flat)](http://blog.codinghorror.com/the-best-code-is-no-code-at-all/)
# StimulusReflex Client
JavaScript client for [StimulusReflex](https://github.com/hopsoft/stimulus_reflex)
This libary is intended to work with the StimulusReflex Ruby GEM.
## Installation
```
yarn add stimulus_reflex
```
## Usage
```html
<!-- app/views/pages/example.html.erb -->
<html>
<head></head>
<body>
<a href="#" data-controller="example" data-action="click->example#doStuff">Do Stuff</a>
</body>
</html>
```
```javascript
// app/javascript/controllers/example_controller.js
import { StimulusReflexController } from 'stimulus_reflex';
export default class extends StimulusReflexController {
doStuff(event) {
event.preventDefault();
event.stopPropagation();
// trigger a server side reflex and a re-render
this.stimulate('ExampleReflex#do_stuff', arg1, arg2, ...);
}
}
```
```ruby
# app/reflexes/example_reflex.rb
class ExampleReflex < StimulusReflex::Reflex
def do_stuff(arg1, arg2, ...)
# computing...
end
end
```
Documentation can be found at: https://github.com/hopsoft/stimulus_reflex

@@ -1,4 +0,3 @@

import { Controller } from 'stimulus';
import ActionCable from 'actioncable';
import CableReady from 'cable_ready_client';
import CableReady from 'cable_ready';

@@ -8,7 +7,7 @@ let timeout;

CableReady.App = {};
CableReady.App.cable = ActionCable.createConsumer();
CableReady.App.subscription = CableReady.App.cable.subscriptions.create(
'StimulusReflex::Channel',
{
CableReady.App = window.App || {};
CableReady.App.cable = CableReady.App.cable || ActionCable.createConsumer();
CableReady.App.stimulusReflexChannel =
CableReady.App.stimulusReflexChannel ||
CableReady.App.cable.subscriptions.create('StimulusReflex::Channel', {
received: data => {

@@ -22,18 +21,19 @@ if (data.cableReady) {

},
}
);
});
class StimulusReflexController extends Controller {
stimulate() {
clearTimeout(timeout);
let args = Array.prototype.slice.call(arguments);
let target = args.shift();
CableReady.App.subscription.send({
url: location.href,
target: target,
args: args,
export default {
register: controller => {
Object.assign(controller, {
stimulate() {
clearTimeout(timeout);
let args = Array.prototype.slice.call(arguments);
let target = args.shift();
CableReady.App.stimulusReflexChannel.send({
url: location.href,
target: target,
args: args,
});
},
});
}
}
export { StimulusReflexController };
},
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc