// my method class
@ReactMethod
public void setCurrentTime(final Integer key, final Float sec) {
MediaPlayer player = this.playerPool.get(key);
if (player != null) {
player.seekTo((int) Math.round(sec * 1000));
}
}
// создается нативный модуль OutputVolume
@implementation OutputVolume
RCT_EXPORT_MODULE();
// Отдает метод get
RCT_REMAP_METHOD(get,
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject)
{
float volume = [AVAudioSession sharedInstance].outputVolume;
NSString* volumeString = [NSString stringWithFormat:@"%f", volume];
if (volumeString) {
resolve(volumeString);
} else {
reject(@"get_error", @"Error getting system volume", nil);
}
}
import { NativeModules } from 'react-native';
const MyNativeModule = NativeModules.MyNativeModule;
for (let prop in checkboxGroup ) {
if (checkboxGroup.hasOwnProperty(prop) && checkboxGroup[prop]['checked']) {
newArray.push(checkboxGroup[prop]['value']);
}
}
Object.keys(checkboxGroup)
.map(key => checkboxGroup[key])
.filter(item => item.checked)
.map(item => item.value)
const newArray = Object.keys(checkboxGroup) // Превращаем объект в массив ключей checkboxGroup
.filter(name => checkboxGroup[name].checked === true) // Создаем новый массив из ключей, в котором будут только те, для которых у объекта - checked есть истина
.map(name => checkboxGroup[name].value); // Создаем новый массив из свойств value
<ol>
<script>
const renderAnswer = (questionId, [id, answer]) => `
<input
type="radio"
name="q${questionId + 1}"
value="${id}"
onClick="Engine(${questionId}, this.value)"
id="test-radio"
/>
${answer}
<br/>
`;
const renderQuestion = (question, id) => `
<li class="test-li">
<span class="quest quote__main">
${question.text}
</span>
<br/>
${
Object
.entries(question.answers)
.map(renderAnswer.bind(null, id))
.join('')
}
`;
questions=[
{answers: {a: 'a option', b: 'b option'}, text: 'foo'},
{answers: {c: 'c option', d: 'd option'}, text: 'boo'},
];
document.writeln(questions.map(renderQuestion).join(''));
</script>
</ol>
<div id="some_id"></div>
var symbol = function(e) {
if (e.keyCode == 38) {
var tId = document.getElementById('some_id'),
copySymb = String.fromCharCode('"\u00A9"');
tId.innerHTML = copySymb;
}
}