Ejemplo n.º 1
0
 componentDidMount() {
   Orientation.getSpecificOrientation((err, orient) => {
     this.setState({orientation: orient});
   });
   this.orientationListener = (orient) => {
     this.setState({orientation: orient});
   };
   Orientation.addSpecificOrientationListener(this.orientationListener);
 }
 it("must call methods without error when send callback function", () => {
   getOrientation((error: ?Error, orientation: ?Orientations) => {});
   getSpecificOrientation(
     (error: ?Error, orientation: ?SpecificOrientations) => {}
   );
   addOrientationListener((orientation: ?Orientations) => {});
   removeOrientationListener((orientation: ?Orientations) => {});
   addSpecificOrientationListener((orientation: ?SpecificOrientations) => {});
   removeSpecificOrientationListener(
     (orientation: ?SpecificOrientations) => {}
   );
 });
 it("must throw error when call async function without callback fn", () => {
   // $ExpectError
   getOrientation();
   // $ExpectError
   getSpecificOrientation();
   // $ExpectError
   addOrientationListener();
   // $ExpectError
   removeOrientationListener();
   // $ExpectError
   addSpecificOrientationListener();
   // $ExpectError
   removeSpecificOrientationListener();
 });
Ejemplo n.º 4
0
 _getSpecificOrientation() {
   Orientation.getSpecificOrientation((err, orientation) => {
     Alert.alert(`Specific orientation is ${orientation}`);
   });
 }