Skip to content

[update] datacollection api descriptions#60

Open
mafanya23 wants to merge 4 commits intomasterfrom
update-datacollection-api
Open

[update] datacollection api descriptions#60
mafanya23 wants to merge 4 commits intomasterfrom
update-datacollection-api

Conversation

@mafanya23
Copy link
Copy Markdown
Contributor

No description provided.

@mafanya23 mafanya23 requested a review from Sorokin-Oleg March 26, 2025 09:17
@@ -12,14 +12,14 @@ description: You can explore the add method of DataCollection in the documentati

@params:
- `new_item: object | array` - the object of a new item or an array of item objects
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mafanya23 посмотри пожалуйста, как в оригинальных типах построена типизация компонентов. В старой документации не было возможности давать больше конкретики. Но сейчас такая возможность есть. Да и на проекте используем TS и отдаем .d.ts

  1. Наименование аргументов, свойств. Обрати пожалуйста на это внимание, мы используем camelCase.
  2. add(newItem: IDataItem | IDataItem[], index?: number): Id | Id[];
type Id = string | number; // Можно где-то про это один раз написать, либо продублировать в паре мест. Метод add() для этого подходит. 
add(newItem: IDataItem | IDataItem[], index?: number): Id | Id[];

(string | number) | (string | number)[] - Можно и оставить. Но Было бы не плохо перейти на Id - он у нас часто встречается.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mafanya23 подход, где мы предоставляем типы будет все же более правильным. Так сейчас делают все современные библиотеки. Главное, чтобы типы были из d.ts, а не абстрактными.

- `item` - the current item of a data collection
- `callback: function` - a function that will be called for each item in the array. The function is called with the following parameters:
- `acc: any` - the *initialValue*, or the previously returned value of the function
- `item: any` - the current item of a data collection
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mafanya23 IDataItem, посмотри пожалуйста и в других местах

@mafanya23
Copy link
Copy Markdown
Contributor Author

Правки по описанию аргументов и типов вынесены в отдельную задачу https://tracker.webix.io/issue/DHX-5160/Improve-description-of-DataCollection-TreeCollection-API

- `id: string | number` - the old id of an item
- `newId: string | number` - optional, the new id; auto-generated if not set
- `silent: boolean` - true, to prevent changing the id; otherwise, false
- `newId?: string | number` - optional, the new id; auto-generated if not set
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mafanya23 да, тут получается, что newId опционален. Но давай сделаем обязательным. Пользователь может не понять, что произошла смена ID при передаче только первого аргумента. Метод явно требует доработок, нужно было бы возвращать новый ID.

Создал задачу на изменение в suite 9.4 - https://tracker.webix.io/issue/DHX-5162/DataCollection.-Update-method-changeId

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mafanya23 тут больше вопрос, а почему jsx? Когда мы используем вставки из TS будет лучше использовать и расширение для отображения кода как ts. Я попробовал, так действительно лучше видны ключевые слова.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Да, в Usage можно использовать вставки кода с ts расширением, тоже посмотрела

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants