Coder Social home page Coder Social logo

Comments (4)

billba avatar billba commented on July 17, 2024

The only problem with the sample code is that switch(connectionStatus) { .. } should be surrounded by curly brackets. I've fixed this in the README, thanks for the bug report.

To answer your question, ConnectionStatus is a TypeScript enum, which really just means that it's a plan old JavaScript object with values for each field. ConnectionStatus.Uninitialized === 0 and so on. If you want a more descriptive log, try console.log(ConnectionStatus[connectionStatus]) which will show the string value, e.g. "Uninitialized".

I'm closing this issue, but feel free to add more comments if you continue to see problems.

from botframework-directlinejs.

gilesbutler avatar gilesbutler commented on July 17, 2024

Thanks for the quick response @billba 👍

Sorry but I'm still slightly confused because if I console.log(ConnectionStatus[connectionStatus]) I get 'ConnectionStatus' is not defined. Is that because I'm not using TypeScript or am I missing something here?

In the example in the docs I can't see where ConnectionStatus is supposed to be defined, is this an RX thing or something that I'm missing?

directLine.connectionStatus$
.subscribe(connectionStatus =>
    switch(connectionStatus) {
        case ConnectionStatus.Uninitialized:    // the status when the DirectLine object is first created/constructed
        case ConnectionStatus.Connecting:       // currently trying to connect to the conversation
        case ConnectionStatus.Online:           // successfully connected to the converstaion. Connection is healthy so far as we know.
        case ConnectionStatus.ExpiredToken:     // last operation errored out with an expired token. Your app should supply a new one.
        case ConnectionStatus.FailedToConnect:  // the initial attempt to connect to the conversation failed. No recovery possible.
        case ConnectionStatus.Ended:            // the bot ended the conversation
    }
);

from botframework-directlinejs.

billba avatar billba commented on July 17, 2024

It's not an RxJS or TypeScript thing, just an object exported from the library. You need to import it. If you're using ES6 modules then you'll need to do something like:

import { DirectLine, ConnectionStatus } from 'botframework-directlinejs';

This is not necessarily obvious so I have updated the code samples with import statements.

from botframework-directlinejs.

gilesbutler avatar gilesbutler commented on July 17, 2024

Ahh that makes way more sense ha. Thanks @billba :)

from botframework-directlinejs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.