question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Please clarify using `DataType` for code completion

See original GitHub issue

Hey, I’m having some trouble with code completion when I do this in my code:

export const loginObservable = createReactObservable<{ user: User | null }>(...)

The code that uses the above:

import { loginObservable } from "user"; // some imported workspace module

const {
  ObservableProvider: LoginProvider,
  useObservable: useLoginObservable,
} = loginObservable;

function App() {
  const { data } = useLoginObservable();
  ///...

Now, in VS Code, when I type data. I don’t get any suggestions for ‘user’ whatsoever. I dug into the library’s types and found:

export type DataType<T> = T | T[] | undefined;

Which is a bit unclear to me. Values in the ‘event bus’ can be either arrays or singular values? If so how would I use this with proper type checking? Thanks.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
amireldorcommented, Jan 8, 2021

Hi @luistak, forgive me for being so late in response!

Your API suggestion looks good. I’d however considered adding a limit to the length of values kept in every just to prevent potential memory issues. Maybe you could use an API like so for every:

const options = { every: true } // keep everything
// - or -
const options = {
  every: { keep: 20 } // keep last 20 values
}

Also, consider all or last as an alternative variable name than every.

1reaction
luistakcommented, Oct 11, 2021

Hi @amireldor the new major version was released along with the improvements we discussed, feel free to use it and please give us feedback if you find any problems or feedback.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Select the Right Data Types | Tutorial by Chartio
This tutorial will explain how to select the right data types. What are Data Types? Data types define what kind and range of...
Read more >
Python: tell my IDE what type an object is - Stack Overflow
So, when I want code completion for help I just instantiate the variable to the type I want and then type ".", for...
Read more >
Data Types in C: Derived and Modifiers | Simplilearn
Check out the data types in C and learn how to implement them while creating programs. Gain an in-depth knowledge of derived, user-defined ......
Read more >
Data types in Java - GeeksforGeeks
Data types are different sizes and values that can be stored in the variable that is made as per convenience and circumstances to...
Read more >
Oracle Data Types with Examples - Complete Guide
In this article, you will learn all about built-in Oracle data types - Character, Numeric, Object, DATE, LOB, RAW and LONG RAW, ROWID...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found