Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Included files #16

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Conversation

ttodua
Copy link
Contributor

@ttodua ttodua commented Jan 24, 2021

It would be nice if the script had a feature to reload the current page, only if any of the related files (which have been used while generating the current page) is changed (as opposed to "any" file change in the project dir, or manually setting the "watch-files" list).

To achieve that, it should have been done the following way:

  1. If user wants to use that approach, he should set the project_dir in the initializer, like: new HotReloader\HotReloader('//localhost/'', __DIR__ )
  2. Then, in "register_shutdown_hook" (when injecting EVENT_SOURCE_ENDPOINT codes in HTML), it should get all files that were involved in page execution, using get_included_files().
  3. Due to possible large-list of included files, instead of query, send the data with Session-ids.
  4. in phrwatcher, make fileslist parameter into array and check if the changed file's path is in that array. If so, send reload signal, otherwise don't send.

This will save much of unnecessary reloads, while we work on the project ALL OPEN TABS are reloaded, when only one file (related to specific page) changes, and it looses all the Client-Side changes on all tabs (i.e. filled forms, JavaScript actions and states on UI), which are not necessary to have changed.
So, this will solve the problem and increase the efficiency.

@ttodua
Copy link
Contributor Author

ttodua commented Jan 24, 2021

Ideally, in my mind (as the script is totally intended for development stage), the variables could be set-able from the initializer , when including lines new HotReloader\HotReloader('....) in our scripts, so i.e.:

new HotReloader\HotReloader(..url.., project_dir, ignored_files, enabled, ...)

those variables could be set there, and thus, disregard changing anything in phrwatcher.php at all. Thus, there will not be need to change 2 files in order to use PHR, and just tell people in readme that they need just set them inside their project (imho, I find a bit complicated readme for newcomers, while many projects tend to give "example usages" in one paragraphs, here the repo has a bit larger readme to understand how to use the project, however, i might be wrong, just my 2 cents).

@moevbiz
Copy link

moevbiz commented Feb 12, 2021

set them inside their project

Yes, that's what I was trying to say here:
#14 (comment)

If the plugin is installed via composer, imo it's absolutely necessary to have to set set the variables only from outside the plugin.

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.

None yet

2 participants