2

I'm creating a single page web application.

I created a basic design for the app structure. This answer about this video was very helpful.

The application contains one html page. The JS code will change it's content. The Usher will supply a module according to the URL (domain.com/#list#item1 will return an item module).

The module will use the sandbox to retrieve data from the server (that will use the Application Core for that). The module will set the page style by passing the sandbox an key-value list and will set the page HTML in this way too.

What do you think about it. Does it decoupled enough?

enter image description here

Community
  • 1
  • 1
Roy Tsabari
  • 2,000
  • 6
  • 26
  • 41

1 Answers1

0

Short answer: Kind of. It depends on how complex your modules are.

Long answer:

I'm working on one application that respects the Core -> Sandbox Instances -> Modules pattern like you described.

The only unanswered question about my application is this:

"What happens when Module A and Module B have a small UI component that is the same, or almost the same?".

In your case, this might be an accordion on 3 modules out of 5. This accordion might be application specific, so simply adding a jquery plugin in core, and exposing it to the modules via Sandbox will just not cut it.

I ended up with two possible solutions:

1) Use the common functionality as a special type of module that can be requested via the sandbox by other modules. This is the case when just one instance of the UI will be visible at a given time - which might be your case -

2) Use a simple prototype instantiation for my reused object and add it as a dependency for all modules that use it.

Vlad Nicula
  • 3,577
  • 6
  • 32
  • 50