-
Notifications
You must be signed in to change notification settings - Fork 4
Viewmodel phosphor widget implementation #4
Conversation
'use strict'; | ||
|
||
import { | ||
ISignal, Signal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two leading spaces.
e5fd283
to
f7e15b5
Compare
@blink1073 - I cleaned up a lot and I think I fixed each one of your comments. |
` | ||
textModel.mimetype = 'text/x-python' | ||
textModel.lineNumbers = true; | ||
/* let inputVModel = new InputAreaViewModel(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leftover?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep....more like, "preview of work to come..."
edb63b7
to
f133220
Compare
@jasongrout, are you ready to merge and iterate on this one too? |
*/ | ||
constructor(model: ITextEditorViewModel) { | ||
super(); | ||
this.addClass('CodeMirrorWidget'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be jp-CodeMirrorWidget
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't realize we had settled on a prefix. Sounds good.
@blink1073 - sure we can merge and iterate from here. |
this.addClass('InputAreaWidget'); | ||
this._model = model; | ||
for (let key in InputAreaWidget.update) { | ||
InputAreaWidget.update[key].call(this, model[key]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is causing a build failure. It should be: InputAreaWidget.update[key].call(this, (model as any)[key]);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👎 on this flavor of dynamic dispatch. It's not type-safe and IMHO is harder to follow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, this was one of the experiments, and I already decided to scrap it. I have some commits deleting it that I haven't pushed.
ping @blink1073 - I switched back to using a switch statement |
this._editor.on('change', (instance, change) => { | ||
this._model.text = this._editor.getDoc().getValue(); | ||
}); | ||
model.stateChanged.connect(this._modelUpdate, this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My convention for naming signal handlers is onThingSignalName
, so for this case it would be _onModelStateChanged
. Not saying you should follow this, just letting you know my convention. This let's me look at a method name and immediately make a good guess as to what it's connected to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. Thanks.
Thanks for the feedback. |
/** | ||
* Change handler for model updates. | ||
*/ | ||
protected _onModelStateChanged(sender: ITextEditorViewModel, args: IChangedArgs<any>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've been using a leading _
for private
only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to leading _
on private
only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Thanks.
Are we ready to merge this then? |
Thanks to @sccolbert for the suggestion.
Interaction with the text should happen through the model. Also, make internal functions protected. Thanks to @sccolbert for the suggestion.
I rebased in order to remove the experimental js code, instead of moving it to a new directory. It's a lot cleaner that way, and the code is still in the history if we want to look at it. |
LGTM, merge? |
I'm ready for it to merge. We'll need to iterate on the tests. |
Yep, iterating, thanks! |
WIP Viewmodel phosphor widget implementation
And now of course I see that I didn't update the readme nor did I delete the js tests... |
This implementation follows design discussions about designing the models.