jamesplease / jamesplease/puppets

Investigate alternative nesting API

Open
#14 2 comments 0 reactions 0 assignees View on GitHub
refactor
Dominant language
No language data
Stars
4
Forks
0
PR merge metrics
No merged PRs in 30d

Description

The current API for showing a view looks like:

``` js
this.showChildView('main', MainView, {force: show});
```

There are two problems with this. The first is the third argument contains both options to pass to `show` (like `force`), but also the view options. I could solve this by having 4 arguments, but...yuck. The other problem with this is that the developer never instantiates the view, which conceals the fact that we're instantiating it with additional options. That additional option is the `el` property, which is pretty important!

Perhaps it would be better make the API more like:

``` js
this.showChildView(new NewMainView({
el: this.region('main')
}), {force:show})
```

This approach solves both problems above without any loss of functionality. Now the third argument is _just_ options for show, and the code clearly shows that the view is being created with an element. It's also just much nicer to create the view yourself, I think.

The `childViews` option would be unchanged, however. That currently looks like:

``` js
var RootView = Puppets.View.extend({
childViews: {
main: {
view: MainView,
options: {color: 'blue'}
},
'.modal': ModalView
}
});
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the existing showChildView and childViews entry points described in the issue and compare how they receive view and show options. Done means reaching a settled decision on the proposed instantiated-view API while preserving the stated childViews behavior; the issue does not name files or tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.