Friday, 7 April 2017

How to asynchronously use _.some

Is there a way to asynchronously use _.some()? I've got the below code snippet that I'm trying to switch to an asynchronous method to prevent it from causing timeout issues.

DLClear = function( obj, squarePt ) {

    var wallPaths = findObjs( {
         _type  : 'path',
         _pageid: obj.get('pageid'),
        layer   : 'walls'
    } );

    var landingPt    = [ obj.get('left'), obj.get('top'), 1 ];
    var wallSegments = PathMath.toSegments( wallPaths );
    var squareSeg    = [ landingPt, squarePt ];

    var blocked = _.some( wallSegments, function( wallSeg ) {
        return PathMath.segmentIntersection( squareSeg, wallSeg );
    } );
    return !blocked;
},

The platform I'm writing for is using javascript ES7 so async/await is usable.

Any and all help is appreciated,

Scott



via Scott Casey

No comments:

Post a Comment