6 ms·
XSM: State management for Angular, React, and Vue
- stingraycharles 7y agoRequest for mods: Title of post currently lacks “for Angular, React, and Vue” which makes it confusing.
- rafaelgarrido 7y agoWould that work with lazy modules in Angular?
- psychometry 7y agoEvery new OSS repo's README should convince me to try it instead of the current standard tools, or at least compare it to them. In my case, I'd want to know what makes it better than Vuex.
- vitriol83 7y agoThat’s rather solipsistic
- kickopotomus 7y agoRationale, motivations, project state etc. are all pretty relevant to any README. In the case of a library that solves a problem which already has known solutions, providing evidence of why your solution is better seems like a no-brainer.
- vitriol83 7y agoThey’re all very relevant, but I try not to expect the same from OSS projects as from a VC pitch deck. After all this is work given freely.
- nerdponx 7y agoOn the contrary, it's too narrow. It shouldn't be limited to open source. IMO any program that isn't a hobby/learning/research project should justify its existence before expecting people to use it.
- hombre_fatal 7y agoA more charitable way I prefer to phrase it: ostensibly you invested time and effort and then shared it with the goal of other people using it, so investing further efforts into the readme helps you achieve this goal even though it might not be as fun as writing code. It's like when someone shares their hobby programming language after investing 100s of hours of work yet didn't even invest 10 minutes writing a "quick start" heading of their readme. I would like to gently encourage them to reach for that low-hanging fruit that's so easy to overlook yet directly serves their goals.
- alexchamberlain 7y agosolipsistic - adjective. of or characterized by solipsism, or the theory that only the self exists, or can be proved to exist -- https://www.dictionary.com/browse/solipsistic https://www.dictionary.com/browse/solipsistic ... in case anyone else had to Google that
- peterluhub 7y agoIt does have the key points listed in the readme. It probably is so obvious. Let me summarize them here. 1. Simplicity - The concepts of XSM are straightforward and easy to grasp. Whereas, the concepts of Vuex are not as easy to understand. 2. Vuex is for Vue only. On the other hand, XSM works Angular, React, and Vue. Learn once and be good with the 3 frameworks. Chance of code reuse with XSM.
- fabiofzero 7y agoLooks better than Redux, but then again what doesn't?
- aarpmcgee 7y agoI still don't quite understand the reasons for the amount of shit Redux gets these days–I find the code (especially when using Redux Starter Kit w/ Typescript) to be easy to debug, easy to read, and easy to maintain. To me, the boilerplate is evidence of a degree of abstraction that may not always be appropriate for every SPA, but in my experience, is still often a really useful and practical choice.
- ng12 7y agoI feel like Redux is a foot-cannon. Too many people use it for simple apps where they take on all the pain but see none of the benefits. I always advise people to avoid it until you're sure you need it.
- acemarke 7y agoWhen you get a chance, please check out our new Redux Starter Kit package. It includes utilities to simplify several common Redux use cases, including store setup, defining reducers, immutable update logic, and even creating entire "slices" of state at once: https://redux-starter-kit.js.org https://redux-starter-kit.js.org It's also written in TypeScript itself, so it works well for TS usage. It doesn't do as much strict magical inference as something like `typesafe-actions`, but it should be very usable. I recently wrote a small example "Github issues" app that's written in TS and uses Redux Starter Kit and our new React-Redux hooks API, if you'd like to see how the code looks: https://github.com/markerikson/rsk-github-issues-experiment https://github.com/markerikson/rsk-github-issues-experiment In particular, here's an example of RSK's `createSlice()` API in action, with TS and some thunks: https://github.com/markerikson/rsk-github-issues-experiment/blob/67691649ce5815158e7f86eefac40df221fd1817/src/features/IssuesList/issues.ts https://github.com/markerikson/rsk-github-issues-experiment/...
- ht85 7y ago
- ng12 7y agoYou could implement this in a dozen lines of code using React.Context. What's the benefit for React specifically?
- ivankolev 7y agoNot affiliated, I just want to throw in Akita https://github.com/datorama/akita https://github.com/datorama/akita from datorama, in the conversation, I have successfully used it in an Angular project, but it's framework agnostic, built on top of rxjs.
- ianstormtaylor 7y agoWhen I see things like this: setcfg({'framework': 'React'}) I immediately think to myself that the designer of the API either (a) values tiny function names over understandable ones, or (b) hasn't given naming enough thought to be consistent. Either way, it's not a good sign and turns me off from investigating further.
- whichdan 7y agohttps://github.com/peterluhub/xsm/blob/master/xsm.js https://github.com/peterluhub/xsm/blob/master/xsm.js The package only exposes 9 functions, and the naming is mostly consistent. There's no benefit to publicly nitpicking function names in something with such a small API.
- rat9988 7y agoHonestly, no need to put much thought in gp's comment. He just wants to show off that he is an experienced engineer that values good code and readability. Edit: for those who disagree and downvote. Not only gp's comment doesn't adress the core issue and is a direct attack to the developer, but it cannot even be accepted as valid and helpful criticism. His point b says that it is possible that the developer doesn't value consistency, while his point a says he might be consistent with short naming. These remarks make it look more like random possible remark than ones that are really specific about this project.
- mythz 7y agoWhilst I'm not a fan of the name, I'm more discouraged that it needs to specify a fx at all which suggests that the library hasn't come up with a generic solution for all fx's but rather a library of quirks to abstract over a limited set of fx's. Since it only has hard-coded support for 3 frameworks, there's no benefit to using magic strings, it would be preferable to use a typed API like: XSM.useReact({ ... }) Where you can provide fx-specific options for each fx it supports. It also hides all the config options available behind a generic API which you have to dive into the impl [1] to see what options are available and what args each config option supports. Everyone would be far better off bringing all config options to the API Surface area, you could easily type-check all options in TypeScript which ensures correct usage of the API and let you know of any additions/removal or breaking changes. [1] https://github.com/peterluhub/xsm/blob/master/xsm.js https://github.com/peterluhub/xsm/blob/master/xsm.js
- digianarchist 7y agoThis project is a month old and maintained by a single contributor. Tread carefully.
- xxxpupugo 7y agoIs there an actual scenario for this? People either picks Angular/React/Vue and live within their respective ecosystem, why would they accommodate themselves with a solution that compatible to all of those but not as good as other state management store that tailored for one of them? I kinda missed the big picture here.
- Octoth0rpe 7y agoHow about if you want to maintain your website in angular, but want to reuse your state management code with a mobile app written in react-native/weex?
- ehutch79 7y agoYou'd honestly be better off rewriting it. And if that's a huge ask, you need to seriously reconsider what is 'global state' in your app. You state management shouldn't really have all your api calls in it. Especially if you're worried about cross platform, put your api interface code into a library, call that from components or your state management. If you find your state management code seems to exist only to call out to your api, it's probably not global state in the first place. Approximately 90% of the time, when people are posting questions about VueX, my first thought, is 'that really doesn't seem like global state'
- williamdclt 7y agoI don't think I get it, what do you use global state for? And what do you use to query your API and store responses then? Most of the time yeah I do use Redux (sagas) to query my API and store the result. Many of my components need access to the same data (who's the current user, what's their list of items, what's the current item being looked at...), so it's at least shared state if not global
- ehutch79 7y agoIt's super dependant on the app. however, abstracting your api calls to a single library is helpful for any app beyond the most simple todo app. Things like the current user are 100% global state. A list of user settings, or valid values for a dropdown that doesn't change often (like a list of timezones, or countries), totally global state. A list of objects only shown on one page or in one component? That component can call an api library for the data itself. State of a component? Definitely not global scope. Specific example; virtual scroll for a table. storing the offset as global scope. As soon as a second instance of the component was loaded on the same page there would be major issues. Data that gets paginated should probably not be in global state, or cached heavily, depending on the app. A couple dozen entries is fine, but the idea of pulling every record in a list from say, an erp app, and then paginating in memory, would wreak havoc on a user's browser. And you're keeping that in the browsers session memory. Not to mention ramifications on the backend, even if it is cached. and then you need to deal with cache invalidation, and then...
- keb_ 7y agoThe fact that it only works with Angular, React, or Vue is a little discouraging (or at least, that's the impression I get by the `frameworkValue` config). Was initially excited to check out a new general-purpose state management solution.
- heracek 7y agoFrom React developer perspective this looks ugly (at least for now). It is dependant on class-based components, it will do nasty modifications to your class instances. You can do much cleaner job using React hooks.
- germs12 7y agoI already have this merged into a feature branch.
- peterluhub 7y agoI have published a github repo that contains the real apps to show how to use XSM to manage app state and handle the API logic to the backend. https://github.com/peterluhub/realworld-example https://github.com/peterluhub/realworld-example It implements the Realworld Example App specs. The state and API logic are factored out into an NPM package(rw-xsm-handlers). The intention is to use the same code(state management and API) for all the XSM supported frameworks to implement the Realworld Example App specs. The React example is finished. Angular and Vue will be added later.