Skip to content

добавлен Service Worker - #36

Open
bulgakovd97 wants to merge 5 commits into
developfrom
43_service-workers
Open

добавлен Service Worker#36
bulgakovd97 wants to merge 5 commits into
developfrom
43_service-workers

Conversation

@bulgakovd97

Copy link
Copy Markdown
Collaborator

Добавление Service Workers

Скриншоты/видяшка (если есть)

TBD (если есть)

Comment thread packages/client/src/index.tsx Outdated
import App from './App';
import ReactDOM from 'react-dom/client';

const startServiceWorker = () => {

@IvanPeleshok IvanPeleshok Jul 16, 2023

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Предлагаю декомпозировать и вынести регистрацию в отдельный модуль (файл)

Дополнительно:
При взаимодействии с асинхронной логикой пользуемся async / await + try / catch
https://learn.javascript.ru/async-await#:~:text=%D0%A2%D0%B0%D0%BA%D0%B8%D0%B5%20%D0%BE%D1%88%D0%B8%D0%B1%D0%BA%D0%B8%20%D0%BC%D0%BE%D0%B6%D0%BD%D0%BE%20%D0%BB%D0%BE%D0%B2%D0%B8%D1%82%D1%8C%2C%20%D0%B8%D1%81%D0%BF%D0%BE%D0%BB%D1%8C%D0%B7%D1%83%D1%8F%20try..catch%2C%20%D0%BA%D0%B0%D0%BA%20%D1%81%20%D0%BE%D0%B1%D1%8B%D1%87%D0%BD%D1%8B%D0%BC%20throw


const url = new URL(request.url);

if (url.origin === location.origin) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Рекомендация: при использовании if стараться оставлять структуру без ветвлений

if () {
  ...
  
  return
}

// else

Comment thread packages/client/src/utils/sw/sw.ts Outdated
];

sw.addEventListener('install', (event) => {
console.log('install', event);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Отладочный код необходим в dev?

@IvanPeleshok IvanPeleshok left a comment

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.

3 participants