Open motss opened 9 months ago
Hi @motss , it depends on the benefits. Currently, a syntax similar to signals can be achieved based on useHost
.
import { html, useHost } from 'atomico';
function myComponent() {
const { current } = useHost<typeof MyComponent>();
return html`
<host shadowDom>
<button onclick=${() => current.value--}>-</button>
<span>${current.value}</span>
<button onclick=${() => current.value++}>+</button>
</host>
`;
}
myComponent.props = { count: { type: Number, value: 0 } };
export const MyComponent = c(myComponent);
customElements.define("my-component", MyComponent);
By the way, I generated a post on Discord at some point to propose an alternative to signals: Discord Post. I invite you to participate on Discord.
Is your feature request related to a problem? Please describe. I knew that there is already an existing
useProp()
anduseState()
which already do their job just nice. I wonder if Signals is a valid feature to be considered inatomico
.Describe the solution you'd like
Describe alternatives you've considered
useState()
does the same thing already.Additional context
Prior arts: