theplant / containers

Better structures for building web applications
1 stars 0 forks source link

Refresh Containers `postEvent` needs to pass in a data parameter #11

Open sunfmin opened 7 years ago

sunfmin commented 7 years ago

For example

  1. FilterOptions container
  2. FilteredProducts container
    • One option: In FilterOptions container if It will post search data to a handler, and the handler did the search, but there is no way to pass that products data into FilteredProducts containers. because refresh those containers is a second request
    • We could store those products somewhere globally like in a database. then when to clear those data is problematic
    • Another Option: postEvent("product_searched", paramObject), then refresh containers will pass the paramsObject to the FilteredProducts container, In the containers, It do the search logic and render products.
sunfmin commented 7 years ago

After some thoughts, the paramObject needs to be pass into containers as url of the page, because we want to change the url of the search even if we only refresh one container of the whole page. that PJAX? https://github.com/defunkt/jquery-pjax

sunfmin commented 7 years ago

maybe I should try to implement the FilterOptions first in React in a Container, to see what do we need.

bodhi commented 7 years ago

Change the URL using JS history to include the search query, and then post the event? When the containers are reloaded, the query will be included, and then the results container will have access to the query.