Blog

Simpla's core library hits v1.0

We completely rebuilt Simpla’s core Javascript library, and released it as a v1.0! Check out the new Simpla on Github, give it a star, tell us what you think.

Why?

We originally designed Simpla as a distributed system, with no ‘core’ that controlled things. Instead, we built a menagerie of utility components that Simpla’s elements used to communicate with each other and the API independently.

While neat in theory, in practice this caused a lot of issues and didn’t offer any practical benefit:

  • Many moving parts were hard to maintain and test.

  • There was a large performance hit with extra Javascript weight added to the page.

  • More than anything it meant Simpla was hard to reason about - which component should be considered the ‘source of truth’? Independent elements and not being a framework was good, but fragmentation was bad.

Enter Simpla v1

Simpla core v1.0 remedies all of these issues, while staying just as flexible. Simpla’s elements still operate independently of each other, while all using the new core Javascript SDK to co-ordinate and talk to the API.

Simpla core now controls the global state of Simpla on your site. Each element observes the global state to know when it should become editable, save/fetch data, etc. The SDK also provides the low-level methods for talking to the API, for things like getting/setting content and logging in/out.

We chose Redux

We decided on Redux as the pattern to model the new Simpla SDK on.

A ‘single source of truth’ was essential in keeping Simpla efficient and scalable, and this is one of Redux’s core principles. Simpla’s data store holds the entire state of Simpla’s ecosystem on your page. This means one place to read from and to update - simple, maintainable and testable.

Another big benefit of Redux is immutable data. The state of your Simpla app is read-only; making changes (like entering edit mode) guarantees a new version of the state, which means reacting to them is trivial.

Finally, sticking to a well defined logic pattern like Redux makes for a more maintainable, scalable codebase. It will allow us to move faster going forward, while not constricting the freedom of individual elements.

Observing changes

Reacting to changes in Simpla can now be done with a simple observe method (full documentation coming soon!). Since the state is immutable, this provides us and other developers in the Simpla ecosystem and seamless mechanism to co-ordinate between elements on a page.

Isn’t Redux for React?

Nope. While Redux is very popular in the React community, it has no inherent relation to React. The patterns and core library are used in many different Javascript environments, and happen to be a perfect fit for Simpla’s ecosystem.

The old simpla-core

You may have noticed that we used to have another, undocumented simpla-core package. That is now deprecated in favour of this new, consolidated library. If you're using the old core package updating to the new one should be fairly seamless.

And that’s it, welcome to the new Simpla! We hope you like it.