Investing amid a market downturn has its advantages and drawbacks. On the one hand, it is not difficult to find stocks trading at much more attractive prices. However, it can be challenging to separate the wheat from the chaff. Not all beaten-down stocks will recover and be solid picks for a decade or more, and investors need to do their due diligence and carefully select those that look the most likely to pull that off.

For those who need inspiration, let's consider two stocks that have been trashed this year but still boast solid, long-term prospects: Tandem Diabetes Care (TNDM 0.43%) and Roku (ROKU 0.15%)

1. Tandem Diabetes Care

In the next decade, Tandem Diabetes Care can count on its disruptive innovations and the increase in the number of diabetes patients to deliver outsize returns. The company's t:slim X2 insulin pump is much easier on people with diabetes than multiple daily injections (MDIs) and Tandem's product provides features that most don't offer, including continuous glucose monitoring integration to automate the insulin delivery system completely. 

That's why Tandem Diabetes Care continues to grow its installed base. As of Sept. 30, it had 400,000 customers worldwide, an increase of 35% year over year. Tandem Diabetes Care's installed base can allow it to generate solid recurring revenue. The t:slim X2 insulin pump's renewal cycle is about five years. The company targets a 70% retention rate.

Tandem Diabetes Care also sells various accessories, such as insulin cartridges, that are replaced relatively frequently. The wider its customer base, the more it can make money from new pump orders and the sale of instruments and accessories. Meanwhile, diabetes is on the rise, meaning Tandem Diabetes Care will have plenty of white space to attract new clients.

Even within the current population of diabetes patients, MDIs still dominate the market in the U.S. and abroad. That bodes well for the company's future. Tandem Diabetes Care did not perform well this year due to marketwide troubles, a slowdown in its revenue growth compared to last year, and the fact that it remains unprofitable. 

TNDM Revenue (Quarterly YoY Growth) Chart

TNDM Revenue (Quarterly YoY Growth) data by YCharts

But sticking with companies that have promising prospects even during downturns is one way to earn solid returns over the long run. Those who do that with Tandem Diabetes Care will thank themselves in 10 years. 

2. Roku

Streaming giant Roku is experiencing a spectacular fall from grace. That may be expected as the company makes much of its money from advertising. And given the difficult economic conditions, businesses have decreased ad spending, meaningfully impacting Roku's top line. The company's revenue growth rate has dropped lately.

ROKU Revenue (Quarterly YoY Growth) Chart

ROKU Revenue (Quarterly YoY Growth) data by YCharts

Add that to an increase in expenses linked to the same macroeconomic headwinds, and Roku's overall business looks to be struggling.

Here's the good news. Ad spending might be down right now, but it will rebound once economic conditions improve, consumers have more money to spend, and businesses return to pouring a lot more money into efforts to attract more customers. Roku ended the third quarter with 65.4 million active accounts, an increase of 16% compared to the year-ago period.

Perhaps part of why it continues to grow its ecosystem is that it has chosen to insulate customers from the higher costs of getting its Roku streaming players on the market. In my view, that is an excellent decision as it will allow Roku to build a larger base of customers, making its ecosystem even more attractive to advertisers once the economy recovers.

And the company still has plenty of growth left in the streaming market. Viewing habits continue to evolve as the streaming industry is still gaining steam.

The more people cut the proverbial cord -- or at least, the less they watch cable -- the more advertisers will follow those eyeballs wherever they go. And they are all turning to streaming. According to media analytics company Nielsen, streaming accounted for 38.2% of television viewing time in November, an increase of 10% year over year. Linear television likely won't completely disappear anytime soon.

Older generations who grew up with it are the most likely to still be connected to cable. In the U.S., 81% of adults age 65 and older still received television via cable or satellite as of last year, compared to just 34% of those age 18 to 29. That's why Roku can still grow by leaps and bounds in the next decade and beyond.

In short, despite its poor performance in the past year, Roku's shares are worth buying right now