-
Notifications
You must be signed in to change notification settings - Fork 3
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
Migrating away from AngularJS #16
Conversation
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.
Great job. I entered several questions, comments, and requests for small changes.
@@ -0,0 +1,49 @@ | |||
# Revisiting Force-Horse: Making a Legacy Plugin Agnostic and Usable |
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.
A very nice blog post and plan. A small point: it seems an exaggeration to call force-horse a "legacy" plugin. It is not that old.. it is just that javascript is developing so fast. I probably wrote it just before ES6 kicked in.
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.
Thanks!
It is legacy, just because AngularJS is legacy, see:
Legacy code refers to an application system source code type that is no longer supported
Yeah, you kind of mixed some ES6 in there, just a bit.
BLOG.md
Outdated
While you can read all of the details on the library in Ram's [blog post](http://webiks.com/force-horse-force-layout-component/), the gist of it is having a library that adapts to many types of data sets, and is easily modifiable for the users, having many modes for nodes, D3.js forces, multiple edges between nodes, supporting any size of data set, and easily allowing customization of the base SVG's design. | ||
|
||
## So... What's New? | ||
Having the library written using AngularJS, forces the user to use a deprecated framework. Either the user thinks they can just include AngularJS in the bundle, increasing the bundle, or trying to implement the component for their used framework. |
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.
A small comment: AngularJS is, of course, not the front version of Angular, but it is not deprecated. It will be with us perhaps for a long time still..
README.md
Outdated
@@ -68,38 +100,37 @@ The config parameters are: | |||
} | |||
``` | |||
|
|||
The forceHorse project contains a complete **demo application**. The demo application is also available on the [plunker](http://embed.plnkr.co/SYmehtaAnQVyMpLJJY2B/?show=preview) site. | |||
The forceHorse project contains a complete **demo application**. The demo application is also available on the [plunker](http://embed.plnkr.co/SYmehtaAnQVyMpLJJY2B/?show=preview) site. |
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.
The demo on plunker is probably out of date
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.
Hahaha probably.
I'll make a new one on the updated code base, as the package is on NPM already (had to test it for the demo)
@@ -0,0 +1,63 @@ | |||
import {ForceHorseProvider} from '../../providers/force-horse'; |
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.
It seems that you have three files with the same name force-horse.js (in different folders). This does not seem to me a good practice. Files tend to travel between folders. Better to have a unique name for each file, like force-horse-component.js, force-horse-helper.js, etc.
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.
Reasonable. Done
src/providers/force-horse.js
Outdated
/** | ||
* Produces a class-instance for each instance of ForceHorse on a page | ||
*/ | ||
export class ForceHorseProvider { |
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.
Why "provider" in the class name? Why not "factory" as it was before?
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.
Because it does not instantiate a service, and just provides logic for the component. Can change if you find this awful
webpack.config.js
Outdated
use: extractSASS.extract({ // Instance 2 | ||
use: [ | ||
'css-loader', | ||
'postcss-loader', |
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.
Why both postcss loader and sass loader?
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.
because I use scss, and because I want autoprefixer for -webkit-mask..
, so sass-loader
for scss, and postcss
for autoprefixer
@@ -0,0 +1,23 @@ | |||
language: node_js |
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 am not so familiar with Travis. What does this file do?
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.
Every commit, travis will automatically try to tests. and report back on github what is the status
If there is a new tag, it will deploy it to a github release, and to an NPM release, hopefully
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.
See below, it shows a PR status
BLOG.md
Outdated
While you can read all of the details on the library in Ram's [blog post](http://webiks.com/force-horse-force-layout-component/), the gist of it is having a library that adapts to many types of data, is easily modifiable for developers, supports large data sets, and easily allowing customization of the base SVG's design. | ||
|
||
## So... What's New? | ||
Having the library written using AngularJS, forces the user to use a deprecated framework. Either the user thinks they can just include AngularJS in the bundle, increasing the bundle, or trying to implement the component for their used framework. |
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.
AngularJS is not, strictly speaking, deprecated. It is still supported, and widely used.
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.
You are right. Changed from "deprecated" to "legacy".
BLOG.md
Outdated
Therefore, we decided to remove the dependency for AngularJS, making the library framework agnostic. | ||
|
||
##### Agnostification | ||
We migrated AngularJS out of the library, moving to a standard browser feature - [Custom Elements](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Custom_Elements), supported by most modern browsers, or being worked on at this time (In case it isn't supported, there is a tiny [browser polyfill](https://github.com/webcomponents/webcomponentsjs) - see [browsers support](https://caniuse.com/#search=custom%20elements%20v0)) |
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.
- Actually you seem to have used here Custom Elements V1, which is not yet (as of 09.17) supported by most modern browsers.
- The link to caniuse.com needs to be fixed (V1)
- Can we ship the polyfill inside our package? (and, say, check whether the browser supports custom elements V1, and if not, automatically load the polyfill)
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.
- Done
- Done
- We can, we shan't imo. It is super simple to add, I can add the code to the README, it is like:
npm i @webcomponents/custom-elements
- Add
<script src="custom-elements.min.js"></script>
orimport from '@webcomponents/custom-elements/custom-elements.min.js'
The reason I think we shan't is that if you use Angular or React or whatever, it is just bloat.
It looks fine, I'm just still a bit uncomfortable with the word "provider"... Did you see the word "provider" used in this way anywhere else? I know the word is used in AngularJS, but it has a different meaning there (a kind of service generator). What do you think about "viewer" instead? Because what you called the force horse "component" is actually a container, wrapping the graph viewer (what you called "provider") and the buttons bars. |
@ramtob Ok, done. |
Good. Just one more little request: instead of forceHorse.instance and this.instance, call it forceHorce.viewer and this.viewer. This will be more informative and readable (this.instance is actually a kind of duplication, since "this" is already an indication for an instance) |
@ramtob Fair point, changed that. |
I approved the PR. Nice work |
Thanks! |
Removing the dependency in AngularJS, moving to custom elements in ES6 and SCSS, more tests, tests coverage, better files structure.
BLOG.md
files is the work in progress blog post to release after merging. It contains all the information on what was done.Fixes:
#2 - Adds a
readyEvent
Event emitter, whenever it redraws (new SVG)#4 - Using an event emitter, can
unsubscribe
Like everything, this needs many many many more tests, as the main provider is not fully covered.