Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Card Unification RFC v2 #234

Closed
wants to merge 3 commits into from
Closed

Card Unification RFC v2 #234

wants to merge 3 commits into from

Conversation

bantic
Copy link
Collaborator

@bantic bantic commented Nov 17, 2015

This is a continuation/distillation of the helpful feedback from #228.

do not merge

rendered

A few notes:

  • ember-based consumers that use ember-mobiledoc-editor or ember-mobiledoc-dom-renderer will not need to change much — the changes involved here are primarily for 1st-level consumers
  • The changes described above de facto mean that cards will be separated by their render context — the same card will not be used for multiple rendering contexts

* [ ] Change card shape to object with `type`, `name`, `render` and optional `edit` properties
* [ ] Card's `type` is validated by renderer (dom renderer cannot render 'text', e.g.)
* [ ] Change arguments passed by editor to card's `render` (or `edit`) method
* [ ] single argument object with `name`, `buffer`, `isInEditor`, `options`, `editorEnv` and `payload` properties
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isInEditor -> isEditing? "in editor" seems funky.

I'm kind of inclined to put it on env, but I'll let is go :-p Just don't want to make this a junk drawer.

editorEnv is actually env very specific to the card. The save etc. editorEnv definitely doesn't seem correct.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered isEditing but to me it implies that the card is in "edit mode" (not "display mode"). isInEditor is intended to capture the fact that the card is being rendered for an editor (whether it is in edit or display mode at the moment). Same thing for editorEnv — that is an object of properties that could be useful when a card is being displayed/edited in an editor. editorEnv.save seems like it would be useful any time for a card in an editor (save(newPayload, false) is the way to update a card's payload without transitioning a card). editorEnv.edit is a no-op when the card is already in edit mode. It's redundant but doesn't seem confusing to me — I wouldn't expect someone to think that calling "edit" again while in edit mode would do something.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok, I think I had the entire meaning of isInEditor wrong. Seems ok, I'm not sure what a better name would be 👍

editorEnv has some limited items like name for cards not rendered by the editor (source).

@bantic
Copy link
Collaborator Author

bantic commented Nov 18, 2015

updated based on feedback

* [ ] Card's `type` is validated by renderer (dom renderer cannot render 'text', e.g.)
* [ ] Change arguments passed by editor to card's `render` (or `edit`) method
* [ ] single argument object with `name`, `onTeardown`, `isInEditor`, `options`, `editorEnv` and `payload` properties
* [ ] Return value of card's `render` (or `edit`) method is appended/concatenated by renderer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the other comments got removed here upon update. My response:

This doesn't make a huge difference either way, but the idea is to simplify things . Leave the rendering to the actual render, instead of doing it in the card.

  • Saves writing appendChild, concatenation, addSubview code in every card, and just let's the renderer do the right thing.
  • appendChild abstractions can be kept in the renderer instead of re-implementing that in cards
  • The current pattern forces using wrapper dom element for cards.
  • Passing in a buffer element opens easier possibilities of users leaking it

I don't understand the iOS argument. You return a UIView and the renderer does addSubview, instead of writing that line in every card.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thanks for the feedback @gdub22. This makes sense, and I'm going to move forward with updating the renderers to work this way (using the return val as the rendered content and handling appending/concatting in the renderer itself)

@bantic bantic mentioned this pull request Nov 18, 2015
15 tasks
@bantic
Copy link
Collaborator Author

bantic commented Nov 24, 2015

implemented in #235

@bantic bantic closed this Nov 24, 2015
@bantic bantic deleted the card-unification-rfc branch November 24, 2015 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants