-
Notifications
You must be signed in to change notification settings - Fork 396
Update and streamline method and type names #584
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
Merged
edgarmueller
merged 1 commit into
eclipsesource:jsonforms2
from
edgarmueller:topic/namings
Jun 19, 2017
+478
−481
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,29 +8,30 @@ export interface DataChangeListener { | |
|
||
/** | ||
* Determines whether this listener is interested in any data change. | ||
* If this returns true, the notifyChange method of the listener will be called. | ||
* @param {ControlElement} uischema the control element that is affected by the data change | ||
* If this returns true, the dataChanged method of the listener will be called. | ||
* @param {ControlElement} uiSchema the control element that is affected by the data change | ||
* @returns whether this listener is interested in the given control element | ||
*/ | ||
isRelevantKey(uischema: ControlElement): boolean; | ||
needsNotificationAbout(uiSchema: ControlElement): boolean; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. uiSchema -> controlElement |
||
|
||
/** | ||
* Represents the listener's logic to be called in case of a data change that | ||
* is relevant to the listener. | ||
* | ||
* @param {ControlElement} uischema the control element that is affected by the data change | ||
* @param {ControlElement} controlElement the control element that is affected by the data change | ||
* @param {any} newValue the changed data value | ||
* @param {any} data the current data value | ||
*/ | ||
notifyChange(uischema: ControlElement, newValue: any, data: any): void; | ||
dataChanged(controlElement: ControlElement, newValue: any, data: any): void; | ||
} | ||
|
||
/** | ||
* The data service that holds the data of a form and maintains | ||
* a list of listeners that are notified whenever the data changes. | ||
*/ | ||
export class DataService { | ||
private changeListeners: Array<DataChangeListener>= []; | ||
|
||
private dataChangeListeners: Array<DataChangeListener>= []; | ||
|
||
/** | ||
* Constructor | ||
|
@@ -43,46 +44,41 @@ export class DataService { | |
/** | ||
* Notifies any data change listeners about a data change. | ||
* | ||
* @param {ControlElement} uischema the affected control element | ||
* @param {ControlElement} controlElement the affected control element | ||
* @param newValue the new value of the data chunk | ||
*/ | ||
notifyChange(uischema: ControlElement, newValue: any): void { | ||
if (uischema !== undefined && uischema !== null) { | ||
const pair = getValuePropertyPair(this.data, uischema.scope.$ref); | ||
notifyAboutDataChange(controlElement: ControlElement, newValue: any): void { | ||
if (controlElement !== undefined && controlElement !== null) { | ||
const pair = getValuePropertyPair(this.data, controlElement.scope.$ref); | ||
pair.instance[pair.property] = newValue; | ||
} | ||
|
||
this.changeListeners.forEach(listener => { | ||
if (listener.isRelevantKey(uischema)) { | ||
listener.notifyChange(uischema, newValue, this.data); | ||
} | ||
}); | ||
this.notifyDataChangeListeners(controlElement, newValue); | ||
} | ||
|
||
/** | ||
* Register the given data change listener. | ||
* @param {DataChangeListener} listener the listener to be registered | ||
*/ | ||
registerChangeListener(listener: DataChangeListener): void { | ||
this.changeListeners.push(listener); | ||
registerDataChangeListener(listener: DataChangeListener): void { | ||
this.dataChangeListeners.push(listener); | ||
} | ||
|
||
/** | ||
* Un-register the given data change listener. | ||
* De-register the given data change listener. | ||
* @param {DataChangeListener} listener the data change listener to be un-registered | ||
*/ | ||
unregisterChangeListener(listener: DataChangeListener): void { | ||
this.changeListeners.splice(this.changeListeners.indexOf(listener), 1); | ||
deregisterDataChangeListener(listener: DataChangeListener): void { | ||
this.dataChangeListeners.splice(this.dataChangeListeners.indexOf(listener), 1); | ||
} | ||
|
||
/** | ||
* Resolve the ref of the given control against the root data. | ||
* | ||
* @param {ControlElement} uischema | ||
* @param {ControlElement} controlElement | ||
* @return {any} the de-referenced data chunk | ||
*/ | ||
getValue(uischema: ControlElement): any { | ||
const pair = getValuePropertyPair(this.data, uischema.scope.$ref); | ||
getValue(controlElement: ControlElement): any { | ||
const pair = getValuePropertyPair(this.data, controlElement.scope.$ref); | ||
if (pair.property === undefined) { | ||
return pair.instance; | ||
} | ||
|
@@ -92,10 +88,14 @@ export class DataService { | |
/** | ||
* Notifies all data change listeners initially. | ||
*/ | ||
initialRootRun(): void { | ||
this.changeListeners.forEach(listener => { | ||
if (listener.isRelevantKey(null)) { | ||
listener.notifyChange(null, null, this.data); | ||
initDataChangeListeners(): void { | ||
this.notifyDataChangeListeners(null, null); | ||
} | ||
|
||
private notifyDataChangeListeners(controlElement: ControlElement, newValue: any): void { | ||
this.dataChangeListeners.forEach(listener => { | ||
if (listener.needsNotificationAbout(controlElement)) { | ||
listener.dataChanged(controlElement, newValue, this.data); | ||
} | ||
}); | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
JsonForms is also not a perfect name. Is this maybe a JsonFormsConfiguration?
But as I don't have a better name for this, I'm fine with it, we just should think about how to name the global variable that is created by webpack
Uh oh!
There was an error while loading. Please reload this page.
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 agree regarding the name of the exported global variable that's created by webpack and I'd probably also name it JsonForms :)
I named it
JsonForms
because I was hoping that this will be the only globar var that is relevant from end-users perspective when extending JsonForms (e.g. when adding styles or UI schemata), but I have no hard opionion on this.