Need to dynamic actions in order to support code splitting
See original GitHub issue#435 showed its possible to write an HoA to encapsulate state+action+view into module and https://github.com/hyperapp/hyperapp/issues/435#issuecomment-340067619 showed its possible to load lazy said module, except for the module actions.
Motivation
Code splitting.
Problem
There is currently no way to add actions dynamically.
Possible Solutions
1. Include addAction
action in app
- solves the problem in the most direct way
2. Include loadModule
action in app
- solves the bigger issue at the same time
3. Merge the concepts of state
and actions
- state is expected to change, so what if we just put state and actions in the same place?
- replace
state
andactions
withroot
, keepview
- allow
root
to hold both data and functions. functions would take in root and slice the tree as it does now - functions return and object which will merge into the subtree of where it lives, it can return both data and more functions (aka actions!)
- since actions don’t need to be there at init time, then modules don’t need to exist either! modules can be put directly on the root or added during init or add lazily later
Option 3 is most interesting to me since it removes even more concepts from Hyperapp.
Issue Analytics
- State:
- Created 6 years ago
- Comments:35 (22 by maintainers)
Top Results From Across the Web
Dynamic actions: How to add new actions at runtime? #533
Summary There is currently no way to add actions dynamically. Why do I want the ability to add actions at runtime? (Code splitting,...
Read more >13.2 Managing Dynamic Actions - APEX - Oracle Help Center
Dynamic actions enable developers to define complex client-side behavior declaratively without the need for JavaScript.
Read more >Code splitting with dynamic imports in Next.js - web.dev
What will you learn? #. This post explains different types of code splitting and how to use dynamic imports to speed up your...
Read more >Dynamic imports and code splitting with Next.js
Dynamic imports, also known as code splitting, refers to the practice of dividing bundles of JavaScript code into smaller chunks, which are ...
Read more >Master code splitting with dynamic imports in Next.js - Daily.dev
js will map to the route /home/home/, the React component exported from the home.js file will be rendered when the route is navigated....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Pyrolistical I have a contrived example with dynamic actions for the
models
branch with a few updates.Here is the code:
Hmm. I may not be fully grasping the use case here, but if we’re talking about code-splitting (so the async loading of modules/parts), then each dynamically loaded module would have to be quite independent (since it can’t know for sure if any of the other modules are loaded or not).
My approach in such a scenario would probably be to have each module as it’s own
app({..})
. One master app to manage the fetch/load/initializing of sub apps.