I Made a Mini Framework with Nested Routing and Lifecycle Hooks on top of ArrowJS #95
anthony-autrey
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I discovered arrowjs recently and decided I wanted to see if I could add some bells and whistles to make developing projects with it easier for me. I decided the main things I'd need are inheritable class components, lifecycle hooks, nested routing, and state management.
Check out the demo, the github repo, and everything in a Stackblitz IDE.
To understand how it works, I'd recommend starting with two files (I attempted to comment them well):
Here are some details pulled straight from the readme...
A component looks something like this:
Then use it in your app like this:
You can add the below functions to your component, and they will be automatically called on their triggering events:
From within a component, access the following properties
The simple routing scheme takes a router configuration and matches routes to RouterView components in your app.
Just set up your routes by initializing a Router and putting RouterView components in your app. These routes will be resolved to the RouterViews and will show the correct elements based on the browser path. You can nest these routes as deeply as you need!
Components (and any other code) can share state through a pattern of Static classes that have a private state, made reactive by arrowjs. Simply import a class and watch for changes across your application.
There are probably a lot of improvements that could be made to this, but I thought I'd share what I have since I've read other discussions here about the desire for implementing lifecycle hooks and nested routing. Thanks for reading! 🙏
Beta Was this translation helpful? Give feedback.
All reactions