Skip to content

Commit

Permalink
Fork Platform with a modified API
Browse files Browse the repository at this point in the history
Reviewed By: sahrens

Differential Revision: D6501208

fbshipit-source-id: c4dbe9d5491f2d42e1a84a61758025e5b2dfa0fe
  • Loading branch information
Brian Shin authored and facebook-github-bot committed Dec 8, 2017
1 parent e76abfa commit 5ee27ff
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Libraries/Utilities/PlatformOS.android.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule PlatformOS
* @flow
*/

'use strict';

export type PlatformSelectSpec<A, I> = {|
android: A,
ios: I,
|};

const PlatformOS = {
OS: 'android',
select: <A, I> (spec: PlatformSelectSpec<A, I>): A | I => spec.android,
};

module.exports = PlatformOS;
25 changes: 25 additions & 0 deletions Libraries/Utilities/PlatformOS.ios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule PlatformOS
* @flow
*/

'use strict';

export type PlatformSelectSpec<A, I> = {|
android: A,
ios: I,
|};

const PlatformOS = {
OS: 'ios',
select: <A, I> (spec: PlatformSelectSpec<A, I>): A | I => spec.ios,
};

module.exports = PlatformOS;

5 comments on commit 5ee27ff

@ohtangza
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brishin Do you mind if I ask the motivation for having this?

@jpshelley
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to @ohtangza comment. To help clarify, why would one use PlatformOS over the current Platform API?

@ohtangza
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jpshelley I agree. Having this kind of unnecessary APIs here and there without described motivation lowers the reputation of React Native.

@janziemba
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sahrens Just why?

@brishin
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code wasn't meant for React Native use directly. It was meant for an FB internal use case that couldn't take in all of the RN dependencies. I believe that it can be deleted now — I will take a look this week into what would be required to do so.

Please sign in to comment.