Skip to content

Hw 07#7

Open
bunin-av wants to merge 13 commits intomasterfrom
hw-07
Open

Hw 07#7
bunin-av wants to merge 13 commits intomasterfrom
hw-07

Conversation

@bunin-av
Copy link
Copy Markdown
Owner

No description provided.

Comment thread oop/oop-02.js
Comment thread oop/oop-02.js
Comment thread oop/oop-02.js
Comment thread oop/oop-02.js Outdated
Comment thread oop/oop-02.js Outdated
Comment thread oop/oop-02.js
Comment thread oop/oop-02.js
} else reject(this.reason)
}

if (this.state === 'fulfilled') {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

С таким подходом есть проблема, что обработчик не виден в this.onRejected, а значит неверно будет обрабатываться ошибка.

Посмотри как это сделано у нас
https://github.com/V4Fire/Core/blob/master/src/core/prelude/structures/sync-promise/index.ts

Comment thread oop/oop-02.js
create() {
const storage = new KVStorage(new strategy())
for (const el of this._settings) {
storage.set(...el)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Фомарльно ты конечно сделал все правильно, но я хотел, чтобы ты объединил разные данные и использовал set один раз, чтобы оптимизировать вставку)

Comment thread oop/oop-02.js
Comment thread oop/oop-02.js Outdated
Comment thread oop/oop-02.js
Comment thread oop/oop-02.js Outdated
Comment thread oop/oop-02.js
Comment thread oop/oop-02.js Outdated
Comment thread oop/oop-02.js
}


return !(this.event.cancelable && this.event.defaultPrevented)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Если уж на то пошло, то реализуй логику stopPropagation и stopImmediatePropagation

Comment thread oop/oop-03.js

function lazy(Constructor, params) {
function lazyConstructor(...args) {
if (new.target) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Вызов без new тоже должен работать

Comment thread oop/oop-03.js
return allKeys
}

const instance2 = new Constructor()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ты создаешь инстанс класса в момемнт вызова функции, что противоречит "ленивой концепции".

Comment thread oop/oop-03.js
for (let key of allKeys) {
if (typeof instance2[key] === 'function') {
instance2[key] = function () {
queue.push(key)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Аргументы нужно также сохранять

Comment thread oop/oop-03.js
const queue = []

for (let key of allKeys) {
if (typeof instance2[key] === 'function') {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Записать свойсв нужно тоже сохранять, использует аксессоры

Comment thread oop/oop-02.js
}

#makeItem(el) {
return {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Сделай отдельный класс лучше

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