Is there alternative to Ember Data or Ember M3?

Hi Folks, I have some state management requirements that I feel ember-data and ember-m do not fulfill (Please correct me if I’m wrong). Requirements:

  1. Model less access to APIs. Our backend APIs don’t follow any set REST standards like JSON:API. I know I can write a REST Adaptor of my own, but I think that still requires a model.
  2. Prop drilling and derivative data. We currently use fetch to load all our data from routes and compute derivative data in the router and controller. I want to avoid this to some extent because these constructs lead to prop drilling in the case of derived data. Because I need to keep passing these down in a large component tree.

Where I’m coming from: I’ve used Redux in the past and it somewhat solved both the problems. The only issue I had with Redux was the amount of boilerplate code especially when the app starts scaling. I don’t want to use ember-redux, since it is not maintained, and not sure if it takes advantage of all the ember constructs correctly.

I’ve never used ember-m3 but from my understanding it sounds like it would at least somewhat meet your needs? Certainly better than Ember Data. But maybe not.

In that case the things that come to mind for me are:

  1. use graphql, sounds like this would really be what you want and there are multiple great Ember client addons. Downside is, of course, that you’d have to modify your backend.
  2. Use your own redux implementation. Depending on your ember version there’s nothing to stop you rolling your own Redux implementation. Of course that could be some work and still leaves the boilerplate problem
  3. Bespoke service(s) and/or class(es). Sounds like the biggest value proposition for wanting something like Redux or Ember Data is the store (to avoid prop drilling, etc). Writing one or more store services is pretty simple and it could hold a lot of the derived state that you currently have at the route/controller level. You could also leverage model-like classes if you so choose. In our app I’ve been working on a lightweight service/class layer to fetch data warehouse queries (since they don’t conform as well to Ember Data which we use for our other API resources). I have a base class which provides simple normalization/etc logic, subclasses define each query “shape”, and a service holds the query task and some of the other boilerplate logic (and eventually caching).
  4. You could look into ember-orbit. I don’t recall offhand if that would fit your use case well or not but it’s the other data layer addon that jumps to mind.

If none of the out-of-the-box addons fit how you’d like feels like your best move is just writing your own. Obviously that can be as easy or difficult as your requirements make it. If you’re just looking for a simple store you’re looking at a fairly trivial amount of work. If you have very specific needs or design constraints you’re looking at a much different scenario and would need to evaluate that complexity vs using a 3rd party library which doesn’t quite fit.

2 Likes