![]() The register function creates a route which says hello to the user, or the whole world if the user doesn’t specify who to greet. It exports the structure Hapi is looking for in a plugin. It does what it needs to do, and then returns or throws an exception.Ī very basic plugin is below. The register function receives a server object and an (optional) options object. The basic structure of a Hapi plugin is simple - it’s an object which exports a structure named plugin containing a function named register() (and a bit of metadata). I knew from previous work that the Hapi server has “extension points” in the request/response lifecycle, which can be hooked into and used to monitor or modify the request or response. Plugin structureĪ Hapi plugin seemed to be the best place to start. I had no intention of actually re-implementing the client - I just wanted to automatically insert the fragment which causes the client code to be loaded and start listening. (This is a rather abbreviated explanation…) When it receives a message indicating a reload is required, it does it. The client runs in the browser - it makes a connection to the server and waits for a message. When changes happen, it sends a message to the client (over WebSocket) indicating which file has changed so it can be reloaded if needed. It also listens for messages from the client indicating URL changes. Setting to Auto start the extension after opening the VS Code. Includes list so that the page just be reloaded when the saved file name/path fits with your setting. Applies changes without reloading when any CSS or image changed. It’s responsible for serving the LiveReload client code, and for monitoring the filesystem for changes. Reloads web pages when any file is created, removed or modified. The LiveReload server accepts HTTP and WebSocket connections (on the same port). The full LiveReload protocol is available for everyone to view. Template changes are visible on manual reload if you turn off caching, but I’ve become used to automatic reloading when developing with Vue. Something I’ve been meaning to address for a while is the lack of a LiveReload plugin for Hapi.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |