Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
ember-set-helper
Advanced tools
A better mut
helper!
{{this.greeting}}
<button {{on "click" (set this "greeting" "Hello!")}}>
English
</button>
<button {{on "click" (fn (set this "greeting") "Hola!")}}>
Español
</button>
The {{set}}
helper returns a function that sets a value. This can be used in
combination with Ember's {{on}}
modifier or component actions to update state
without having to write your own custom action. For simple cases, this is pretty
handy:
<button {{on "click" (set this "greeting" "Hello!")}}>
English
</button>
If you do not provide a value to the set
helper, it will set the value that is
provided to it when called. For example:
<!-- app/components/counter.hbs -->
{{this.count}}
<button {{on "click" this.updateCount}}>Add 1</button>
// app/components/counter.js
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
export default class Counter extends Component {
@tracked count = 0;
@action
updateCount() {
this.count++;
if (this.args.onClick) {
this.args.onClick(this.count);
}
}
}
<!-- usage -->
<Counter @onClick={{set this "currentCount"}} />
This will set the value of this.currentCount
to whatever value is passed to it
when it is called (in this case the count
of the counter component whenever a
user clicks the button).
You can pass a path dynamically using to the helper as well:
<button {{on "click" (set this this.greetingPath "Hello!")}}>
English
</button>
ember-composable-helpers
With the {{action}}
helper and modifier, you could specify a value path using
the value
named argument:
<input {{on "input" (action (mut this.value) value="target.value"))}}/>
You can accomplish the same thing with {{set}}
by using the {{pick}}
helper
from ember-composable-helpers
to first pick the value off of the event, and then pass it to {{set}}
:
<input {{on "input" (pick "target.value" (set this "value"))}}>
mut
(set this "foo")
=== (fn (mut this.foo))
)(set this "foo" "bar")
=== (fn (mut this.foo) "bar")
)ember install ember-set-helper
See the Contributing guide for details.
This project is licensed under the MIT License.
FAQs
A better `mut` helper!
The npm package ember-set-helper receives a total of 15,040 weekly downloads. As such, ember-set-helper popularity was classified as popular.
We found that ember-set-helper demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.