Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Operator proposal: includes #337

Open
sagdeev opened this issue Sep 17, 2024 · 0 comments
Open

Operator proposal: includes #337

sagdeev opened this issue Sep 17, 2024 · 0 comments
Labels
RFC Some new feature that should be discussed

Comments

@sagdeev
Copy link

sagdeev commented Sep 17, 2024

Hi! I don’t think I’ve seen the operator for the includes method, but it can be very useful. What do you think about it? Also, it is possible to combine includes for arrays and strings.

const $array = createStore([1, 2, 3]);
const $string = createStore('Hello world!');

const $findInArray = createStore<number>(1);
const $findInString = createStore<string>('Hello');

const $isInclude = includes($array, 1);
const $isInclude = includes($array, $findInArray);

const $isInclude = includes($string, 'Hello');
const $isInclude = includes($string, $findInString);

Instead of combine

const $array = createStore([1, 2, 3]);
const $string = createStore('Hello world!');

const $findInArray = createStore<number>(1);
const $findInString = createStore<string>('Hello');

const $isInclude = combine($string, $findInString, (string, findInString) =>
  string.includes(findInString),
);
@sergeysova sergeysova added the RFC Some new feature that should be discussed label Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFC Some new feature that should be discussed
Projects
None yet
Development

No branches or pull requests

2 participants