You can usually see it coming if you look at cash sensitivity of the company. However, large corporate layoff decisions can sometimes be political and have nothing to do with cash flow. And there are SEC rules that prevent large public companies from telegraphing big moves internally before they are announced to the public (to prevent insider trading).
As an example, my entire 80-person group (a sub-division of a large, well-known electronics company) showed a new product at CES one week and was completely shut down the next with no warning (noon meeting to tell you to pack your things by 5). The president just changed his mind on the product we developed. They had to provide 90 days severance to meet layoff notice requirements, but the order to pack your bags was out of the blue to most everyone.