DirectLine-JS Rewrite and Modernization#111
Closed
justinwilaby wants to merge 4 commits intomasterfrom
Closed
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is a complete rewrite and modernization effort for DirectLine-JS with several goals in mind. After some discussion with others in the team, we all agree that DirectLine could be much better.
Motivation
Current State of DirectLine-JS
The current implementation of DirectLine-JS uses libraries and patterns that steepen the learning curve, contribute to very large file size (67k minified), present unnecessary challenges with its use in Node and make meaningful unit testing difficult. These create friction for adoption and make community-driven contributions less likely. Consuming DirectLine-JS forces the developer to also take the RxJS as a dependency and requires a moderate understanding of Observables which dramatically increases file size and makes rapid prototyping harder for those not familiar with it.
Rewrite Goals
The goals of the rewrite are as follows:
for...ofloops,awaitandasyncyou already know how to use this rewriteDirectLineclass in cases were its functionality needs to be augmented by the developer.Building from sources
Clone the repo and switch to the
v1branch and run this command:npm i && npm run buildUsage
The
DirectLineclass is iterable with afor...ofloop. Each iteration delivers aPromisewhich will resolve with either aConnectionStatus, indicating a change in connectivity to a conversation, or it will resolve with an array ofActivityobjects indicating activity within the conversation. A singleDirectLineinstance can service any number of consumers that wish to receive these messages.Below is an example of basic, yet complete usage:
Final Thoughts
I'd like to start the discussion with this PR and am interested in the community's response. I am open to comments and suggestions!