Stepper motor's continuous motion

Hello all, I have a problem that giving continuous movement to a stepper motor untill it interrupted with a sensor's output. We must write an integer value to the step() function in stepper.h library, is there any way to change this instruction to "go straight until reaching desired sensor value" ? Thank you in advance. Best regards.

go straight until reaching desired sensor value

I'm not sure what you mean by this. Presumably, you are using stepper motors because you want to step the motor some discrete number of steps to move something a discrete, known, controlled distance.

If you want that something to keep moving until it trip a limit switch, move it one step and test the switch. Repeat as required (using a while loop), until the limit switch (or other condition) is tripped (or true).