WASHINGTON — President Trump’s regular threats to close down parts of the government to vindicate an applause line make you almost nostalgic for the shutdowns of the past.

When Sen Ted Cruz, R-Texas, pushed the government to a 16-day halt in 2013 in an effort to repeal the Affordable Care Act, at least he was fighting over something that mattered.

I said “almost” about that nostalgia because the closure Cruz championed was, from the beginning, a doomed tactical ploy for a wrongheaded objective. Josh Holmes, a former aide to Senate Majority Leader Mitch McConnell, R-Ky., called Cruz’s gambit “a toddler’s version of legislating.”

That Trump’s fixation over a useless border wall looks even more juvenile than a preschooler’s tantrum explains why Republicans, including McConnell, finally said “Enough!” to a president they had been coddling for fear of retaliation and in the pursuit of conservative dominance over the federal judiciary. This time, they told him he had to surrender his wall-funding dreams.

But the Republicans did not come to this realization entirely of their own accord. A little over a month ago, the same McConnell said he would not bring budget legislation to the floor that he knew the president would veto. The result was the wrenching 35-day shutdown.

McConnell did not reckon with the impact of Democratic control of the House of Representatives. With power in her hands, House Speaker Nancy Pelosi, along with Senate Minority Leader Chuck Schumer, refused to accommodate a presidential objective they knew was phony and, worse, racist in its underlying motivation. This is why Pelosi (to much hand-wringing) called the wall “immoral.”

The president’s proclivity to tweet or talk without much reflection was helpful on this front, too. On Sunday, he picked up on a Gallup Poll suggesting, as Trump put it, that “Open Borders will potentially attract 42 million Latin Americans.” He added: “This would be a disaster for the U.S. We need the Wall now!”

So we know it’s “Latin Americans” in general and not just those “criminals” he talks about whom Trump sees as the grave danger. And, by the way, the compromise spending bill shows that Democrats have no interest in “open borders.”

Trump’s lost mojo with Senate Republicans creates a new playing field. Republicans can see what a 2020 thumping would look like in the nearly 10-million-vote margin Democrats won in the 2018 House races. They also learned from the price they paid for the last shutdown that they will be blamed for the president’s shenanigans.

Meanwhile, Trump shows no signs of backing down from his fantasy approach to public communications. He updated his “Build the Wall!” slogan into “Finish the Wall!” as if he has achieved something he has not.

Noting Trump’s recent statement that “we’re building a lot of wall,” The New York Times calmly reported: “In fact, no new walls have been built or financed by Congress based on the prototypes that the Trump administration unveiled in October 2017. Projects to replace or repair about 40 miles of existing barriers have been started or completed since 2017.”

But Democrats need to learn lessons from all this, too. First, they should stay tough. Second, they need to be disciplined.

This episode shows that standing up to Trump’s worst instincts will pay rewards. Democrats forced Senate Republicans into a very old-fashioned conference committee that reached a budget deal in a very old-fashioned way because the legislators were operating in a largely Trump-free zone. This only happened because Democrats resisted calls to play Trump’s game. “Comity” and “civility” are never achieved by capitulating to bullying and hostage-taking.

At the same time, the GOP, including Trump, is already signaling that its main goal is to pick up on the most adventurous proposals from Democratic legislators — and any reckless or offensive statements from individual Democrats — to pretend that Republicans are, against the evidence of the last two years, a mainstream bunch.

Dealing with this issue is much trickier. For the long run, it’s useful for progressive Democrats to push the boundaries of the policy debate. But they should leave the incendiary tweets to Trump, keep the focus on his extremism, and legislate in areas where their party is united — political reform, voting rights, repairs to the health care system, protections for the Dreamers, and infrastructure.

Successful parties manage to do more than one thing at the same time. To keep the initiative, the Democrats need to show that they can master this essential political art.