Sending Messages with the ChannelMessaging API
HTML-код
- Опубликовано: 4 окт 2024
- If you want to send messages between two windows, two tabs, or a page and a service worker, and you want those messages to only be accessible between two end points then ChannelMessaging is what you want.
Code from video: gist.github.co...
I am LOVING your tutorials! 👏🏼 I've learned so much from you! I am stuck though... maybe I have missed something. Let's say I want to cache different files according to a user selection (say an in-app dropdown for example). Would I simply adjust the PRECACHE_URLS array from within app.js?? Or is there some other technique specific to service workers?
In this video I talk about working with the Cache - ruclips.net/video/zq2xD-xuIG4/видео.html - it will likely help answer your question.
I have another video about working with the Cache and Promises coming out tomorrow.
The cache methods are the same both inside a service worker and in your main script.
@@SteveGriffith-Prof3ssorSt3v3 Thanks heaps! Understanding that the cache can be accessed within the main script as well was key :)
Thank you for the great content🙏🏾
Can you explain FinalizationRegistry and WeakRef in JavaScript
You can make tutorial requests in the comments here - ruclips.net/video/LCezax2uN3c/видео.html
Thank you 🙏
are service workers shared between several tabs on a single machine? or can it be shared between different clients on different parts of the globe?
Service Workers are shared by all tabs and windows belonging to the same origin that installed the worker. Every time a new window or tab is opened that belongs to that origin, the service worker is connected. The service worker exists on one computer in one browser only. Firefox, Opera, Edge, and Chrome would all have their own copy.
One question: there are many react clones of popular websites tutorial on youtube, can we code a clone and add to our public github repository ? I don't want to use it for any business or sell it to somebody. I want to use it just to get job, that shows my skills, so is it illegal to code for example google clone and add it to my public github repository?
There is nothing illegal about coding your own clone of another website to demonstrate your understanding of how to do something with React.
However, if you are just following a tutorial and then using the result of that tutorial on your portfolio, then employers will recognize that immediately and will definitely think twice about what you are actually able to do.
@@SteveGriffith-Prof3ssorSt3v3 so if i code google clone also using google logo and google api for search and add it to my public github repo deployed to be used for non commercial, its ok ? Some people say its illegal
@@waleedsharif618 If you are using logos that is copyright infringement. You have to create your own images and change the name of the company.
It is the functionality that you are cloning for your own repo / portfolio.
@@waleedsharif618 I can tell you first-hand Google won't allow advertising them in your repo or on your website using their logos. I was asked to remove their logos even though I was referring to a project we worked together on
this messaging api looks the most useless compared to the broadcast channel api, clients api, window messaging. what is this for?
Broadcast api works well when you have an unknown number of clients. You can create lots of different channels - one for each topic and the clients can listen to only the ones they want. Simple to set up and use. Works similarly to the pub sub design pattern.