effector / effector/patronum

Operator proposal: `includes`

Open
#337 0 comments 2 reactions 0 assignees View on GitHub
RFC
Dominant language
TypeScript
Stars
312
Forks
48
PR merge metrics
No merged PRs in 30d

Description

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](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes) and [strings](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes).

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

const $findInArray = createStore(1);
const $findInString = createStore('Hello');

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

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

Instead of combine
```ts
const $array = createStore([1, 2, 3]);
const $string = createStore('Hello world!');

const $findInArray = createStore(1);
const $findInString = createStore('Hello');

const $isInclude = combine($string, $findInString, (string, findInString) =>
string.includes(findInString),
);
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.