State Subscription
Advanced State Operations - Subscriptions
Introduction
Filtering Values
import { render, State, $, StateModify } from '@weblabsjs/core';
import { div, p, input } from '@weblabsjs/core/components';
function App() {
const inp = State<string>('');
inp.subscribe("set", (prev: string, newv: string) => {
return StateModify<string>(newv.replace(/apple/gi, "*****"))
})
return div(
p('Hello World'),
input()
.prop('placeholder', 'Enter text')
.event('input', (e) => inp.set(e.target.value)),
$(() => p(inp.get()), inp)
);
}
render('app', App());Setting up Read Filtration
Other subscriptions
Last updated